The typeid operator returns a const reference to a type_info object that describes type-id or the type of expression. If expression is an lvalue (not a pointer) of a polymorphic class, the type_info of the most-derived class is returned. Otherwise, expression is not evaluated, and the type_info of its static type is returned. Each distinct type has its own associated type_info object, but type synonyms (such as those created with typedef) have the same type_info object. Exampletemplate<typename T> void debug(const T& obj) { std::clog << typeid(obj).name( ) << ':' << &obj << '\n'; } See Alsoexpression, typedef, Chapter 3, <typeinfo> |