typeid
keyword
Introduced in CS247, when introducing the Liskov Substitution Principle.
typeidreturns
std::type_info` objects that can be compared.
Difference between
typeid
anddynamic_cast
?
typeid
: Isother
exactly aCircle
? Doesn’t consider inheritance.dynamic_cast
: Isother
aCircle
, or a subclass ofCircle
? Considers inheritance.
typeid uses the dynamic-type so long as the class has at least one virtual method.