这个号码和我的typeid有什么关联
What is this number associated with my typeid?
程序:
#include<iostream>
#include<typeinfo>
using namespace std;
class Base
{
public:virtual void func(){}
};
class Derived1 : public Base {};
int main()
{
Derived1 d;
cout<<typeid(d).name()<<endl;
return 0;
}
输出:
8Derived1
这个数字是多少8?
编译器:g++-4.8.4-2ubuntu1~14.04
它是实现定义的,没有固有的含义。检查std::typeinfo::name()引用:
返回一个实现定义的以null结尾的字符串,该字符串包含类型的名称。没有给出任何保证,特别是,对于几种类型,返回的字符串可能是相同的,并且在同一程序的调用之间会发生变化。
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 警告处理为错误这里有什么问题
- 什么时候调用组成单元对象的析构函数
- #定义c-预处理器常量..我做错了什么
- 努力将整数转换为链表。不知道我在这里做错了什么
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 什么时候在C++中返回常量引用是个好主意
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- C++避免重复声明的语法是什么
- c++库的公共头文件中应该包含什么
- 什么是关联容器?必须更改此容器的QList
- 什么是关联容器
- 什么是用于对数据进行分组的最佳关联容器
- 我对编译时关联容器的选择是什么
- 这个号码和我的typeid有什么关联
- 销毁对象和释放关联内存有什么区别
- 唯一关联哈希映射容器与关联哈希映射集装箱的属性是什么
- 将互斥锁与其数据相关联的正确方法是什么?
- 关联数组的含义是什么?
- 键值关联容器中的顺序是有用的用例是什么