话不多说给出函数,读者可自行测试
函数 typeid(type);
包含在头文件 #include <typeinfo>
简单测例:
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
cout<<typeid(int).name()<<endl;
}
输出:
i
输出为string 或 char* 类型也就是 typeid(type).name() 的返回值
具体什么类型输出什么字符读者可自测。。。ヾ(๑╹◡╹)ノ"撒花