4.6.3 继承中的对象模型
父类中所有非静态成员属性都会被子类继承下去
父类中私有成员属性是被编辑器隐藏了, 因此访问不到, 但确实被继承下去了验证方法:
- 利用开发人员命令提示工具查看对象模型
- 跳转盘符 F:
- 跳转文件路径cd 具体路径下
- 查看命名
c1 / dl reportSingleClassLayout 类名 文件名
代码:
#include<iostream>
using namespace std;//继承中的对象模型class Base
{
public:int m_A;
protected:int m_B;
private:int m_C;
};class Son : public Base
{
public:int m_D;
};void test01()
{//16//父类中所有非静态成员属性都会被子类继承下去//父类中私有成员属性是被编辑器隐藏了, 因此访问不到, 但确实被继承下去了cout << "size of Son = " << sizeof(Son) << endl;
}int main()
{test01();system("pause");return 0;
}