C++:获取基本变量的类型

方法:

typeid(变量).name()


代码:


/**获取变量类型*/

#include<iostream>
#include<string>
#include<typeinfo>

using namespace std;

int main(){

	string pp = "dagah";

	cout<<typeid(pp.at(pp.length()-1)).name()<<endl;

	return 0;
}



运行结果:


原文地址:https://www.cnblogs.com/musecho/p/11989886.html