编程语言
首页 > 编程语言> > C++ typeid获取类型信息

C++ typeid获取类型信息

作者:互联网

#include <iostream>
#include <typeinfo>

int main()
{
   int i;

   const std::type_info &info = typeid(int);
   std::cout << "typeid " << info.name() << std::endl;

   if(info == typeid(i));
   {
      std::cout << "do something" << std::endl;
   }

   return 0;
}
$ ./a.out       
typeid i
do something

标签:std,typeid,main,类型信息,int,C++,info,include
来源: https://www.cnblogs.com/zhangxuechao/p/16593669.html