c++ provides two ways to get information about object at run time this is called RTTI ( Run time type identification). using RTTI we can get the exact type of the object using pointer or reference to the base class.

(1) typeid() operator. { to use typeid() operartor we need to include header “typeinfo”.
(2) dynamic_cast operator.

sample code for typeid():


using namespace std;

class A{
int main()
    A obj;
return 0;

dynamic_cast example:

for dynamic_cast uses and tutorial read this link http://wikistack.com/c-type-casting-tutorial

Related Contents to follow