Information About

Typeid





EXAMPLES


Supposing that you had class "Message" a derived class "FatMessage":...

class Message {
string n;
};

class FatMessage : public Message {
string p;
};

..., and the following code:

  • n = new Message();

  • p = new Message();

  • n).name();


  • p) << endl;

  • cout << typeid(p) << endl;

cout << wakka << endl;

Then, typeid would return the following results in code compiled with RTTI:

FatMessage
Message
Message

Important: Note that you had to dereference the pointer in the first printf.