#include<typeinfo>using std::cout;int main(){ int i; cout << typeid(i).name(); //输出结果为int return 0;}使用函数typeid()即可获得变量的类型。 需要引头文件< typeinfo >