typeid ----返回指针或引用所指向的对象的实际类型
1.typeid--运算符
2.运行时获得了变量类型
3.typeid可用于动态类型,也可以用于静态类型,分别是在运行时和编译时
typeid(变量).name()
4.对于非引用,typeid是在编译时期识别的,只有引用类型在运行时识别
class A
{
};
void main()
{
int a = 1;
char b = 'a';
unsigned char c = 'c';
signed char d;
double e = 23.45;
short f = 3;
A aa;
int* p = nullptr;
A* pa = &aa;
cout << "a typeid = " << typeid(a).name() << endl;
cout << "b typeid = " << typeid(b).name() << endl;
cout << "c typeid = " << typeid(c).name() << endl;
cout << "d typeid = " << typeid(d).name() << endl;
cout << "e typeid = " << typeid(e).name() << endl;
cout << "f typeid = " << typeid(f).name() << endl;
cout << "aa typeid = " << typeid(aa).name() << endl;
cout << "p typeid = " << typeid(p).name() << endl;
cout << "pa typeid = " << typeid(pa).name() << endl;
}