class foo { public: void say_type_name() { std::cout << typeid(this).name() << std::endl; } }; int main() { foo f;; f.say_type_name(); } <
std::type_info::name() returns an implementation specific name. AFAIK, there is no portable way to get a "nice" name, although GCC has one. Look at abi::__cxa_demangle().
std::type_info::name()
int status; char *realname = abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status); std::cout << realname; free(realname);