19.9 RUN TIME TYPE INFORMATION RTTI

Finding the data type of the variable while a program is running is known as Run Time type Information (RTTI). You will ask me what the great deal is. If I have declared int mymarks; I know that myMarks are of type integer. Even if I am working in a group, my colleges are supposed to inform me the data types of the variables they declare.

Fine, this is only part of a story. In the chapter on polymorphism, we have seen that a pointer to base class can point to object of the derived class. Pointers have capability to change during program. Therefore, when a program is executed, it is not possible to tell for sure where (which data type) a pointer is pointing. Hence, the C++ language has introduced the feature ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.