#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
int a;
protected:
int b;
private:
int c; // 私有成员只是被编译器 隐藏了 但是Son还是会继承这个属性
};
class Son : public Base
{
public:
int d;
};
void testSizeof()
{
// sizeof = 16
cout << "sizeof_Son is " << sizeof(Son) << endl;
}
int main()
{
testSizeof();
return 0;
}
C++ 继承中的对象
最新推荐文章于 2024-04-24 15:15:48 发布