In C++, the typeid operator returns a reference to a type_info object, which describes the type of the object to which typeid is being applied. typeid has this general form:
typeid supports runtime type identification (RTTI) in C++. Your program must include the header <typeinfo> in order to use typeid.
The type_info class defines the following public members:
bool operator==(const type_info &ob) const; bool operator!=(const type_info &ob) const; bool before(const type_info &ob) const; const char *name( ) const;
The overloaded == and != provide for the comparison of types. The before( ) function returns true if the invoking object is before the object used as a parameter in collation order. (This function is mostly for internal use only. Its return value has nothing to do with inheritance or class hierarchies.) The name( ) function returns a pointer to the name of the type.
When typeid is applied to a base class pointer of a polymorphic class, it will automatically return the type of the object being pointed to. (A polymorphic class is one that contains at least one virtual function.) Thus, typeid can be used to determine the type of object pointed to by a base class pointer. The same is true for a base class reference.
typeid is not supported by C.