⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtti.cpp

📁 这个是我们学校用的VC++教案
💻 CPP
字号:
#include  <typeinfo.h>			// 为了使用typeid运算符,必须包含该头文件
#include  <iostream.h>
class  CMyClass	{  };			// 定义类
void  main()
{
	CMyClass  my;
	cout<<"Class Name of my: "<<typeid(my).name()<<endl;	// 输出类名
	int  i=12345;
	if(typeid(i)!=typeid(my))								// 运行时识别对象的类型
		cout<<"The type of i is not CMyClass !"<<endl;
	if(typeid(i)!=typeid(float))
		cout<<"The type of i is not float !"<<endl;
	if(typeid(i)==typeid(123))
		cout<<"The type of i is int !"<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -