#include<iostream>
using namespace std;
//父类
class A {
public:
int a;
protected:
int b;
private:
int c;
};
//子类
class B :public A{
public:
int bb;
};
void test01()
{
cout << "sizeof B=" << sizeof(B) << endl;
}
int main()
{
test01();
return 0;
}
一个 int有4个字节。可以看到,子类在继承父类时,无论什么权限,都把父类的属性都继承了下来
使用VS工具认证:
//利用开发人员命令提示工具查看对象模型
//跳转盘至对应文件磁盘(假设C) C :
//跳转文件路径 cd 具体路径下 cd 路径地址
dir查看文件是否存在 (可跳过)
//查看类名,输入:
cl /d1 reportSingleClassLayout类名 文件名