typeid operator
From Cppreference
Queries information of a type.
Used where the actual type of a virtual base class must be known.
Contents |
[edit] Syntax
typeid( type ) | (1) | ||||||||
typeid( expression ) | (2) | ||||||||
Header <typeinfo> must be included before using typeid operator.
Both versions return an object of type const std::type_info&.
[edit] Explanation
1) returns the type information about the type. The type will be definitely known compile time and no runtime overhead is caused.
2) expression is evaluated and type information corresponding to the resulting value is returned. If the expression in a virtual base class, the actual type of the class is queried dynamically with some runtime overhead. Otherwise the actual type is definitely known compile time and no runtime overhead is caused.
[edit] Keywords
[edit] Example
This section is incomplete |