It’s a relatively new conception in C++, you should avoid using it on
old C++ compiler.
It only work with class hierarchy that has virtual functions.
two methods: typeid, dynamic_cast
Always assign the address of a derived-class object to a base-class
pointer. It can be called Up casting.
dynamic_cast help you to assure up casting, when you do down casting,
it will return NULL pointer. Upcast is allowed because it follow the
is-a relationship.
typeid operator will return a type_info class. You need to include
typeinfo.h head file. Typeid receive pointer or class name.
If you just want to assure up casting and you don’t want to know more
about the class, you should prefer to use dynamic_cast . just know
typeid when you have a more complicated demand, you can come back
to take a look deeply.