关于typeid和typeof

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.

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

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

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

原文地址:https://www.cnblogs.com/zhjh256/p/9308427.html