C++如何输出类型信息
#include "stdafx.h" #include <typeinfo> using namespace std; template<class T> class Cat { public: void eat() { printf("eat %s",typeid(T).name()); } }; class Fish { }; int _tmain(int argc, _TCHAR* argv[]) { Cat<Fish> cat; printf("%s \n", typeid(cat).name()); // class Cat cat.eat();//eat class Fish getchar(); return 0; }