August 2012
Intermediate to advanced
976 pages
30h 17m
English
Run-time type identification (RTTI) is provided through two operators:
• The typeid operator, which returns the type of a given expression
• The dynamic_cast operator, which safely converts a pointer or reference to a base type into a pointer or reference to a derived type
When applied to pointers or references to types that have virtual functions, these operators use the dynamic type (§ 15.2.3, p. 601) of the object to which the pointer or reference is bound.
These operators are useful when we have a derived operation that we want to perform through a pointer or reference to a base-class object and it is not possible to make that operation a virtual function. Ordinarily, we should use virtual functions if ...
Read now
Unlock full access