typeid和typeof是c++/gcc编译器的两个关键字,也就是操作符,所以他们根本就不会声明在头文件中。

只不过typeid返回的是type_info,它定义在<typeinfo>头文件中,同时,要使用typeid,就必须先包含该头文件。如下:

This header defines types used related to operators typeid and dynamic_cast.

The inclusion of this header is required prior to any use of the typeid operator.

关于typeid和typeof_typeid和typeof

可是这还有个问题,为啥vs中,typeid有错误提示呢,如下?

关于typeid和typeof_typeid和typeof_02

一直没找到点在哪里,有知道的大神帮忙留个信息。

https://msdn.microsoft.com/zh-cn/library/fyf39xec.aspx

 

花若盛开,蝶自飞来,你若精彩,幸福开怀!2020年12月11日-18日