https://blog.youkuaiyun.com/ASJBFJSB/article/details/81347164
头文件:#include<typeinfo>
在上头文件中定义了typeid()操作符可以输出变量的类型。
#include<iostream>
#include<typeinfo>
using namespace std;
int main(){
bool a;
char b;
short c;
int d;
long e;
float f;
double g;
long long h;
cout<<typeid(i).name()<<endl;
cout<<typeid(a).name()<<endl;
cout<<typeid(b).name()<<endl;
cout<<typeid(c).name()<<endl;
cout<<typeid(d).name()<<endl;
cout<<typeid(e).name()<<endl;
cout<<typeid(f).name()<<endl;
cout<<typeid(g).name()<<endl;
cout<<typeid(h).name()<<endl;
return 0;
}

本文介绍如何使用C++中的typeid操作符来输出基本数据类型的名称。通过简单的代码示例展示了如何利用<typeinfo>头文件获取并打印变量的类型。
650

被折叠的 条评论
为什么被折叠?



