继承中的对象模型
PS:
父类中所有非静态的成员都会被子类继承
父类的私有成员不可访问,但仍会被子类继承
#include<iostream>
using namespace std;
class Base1
{
protected:
int m_B;
private:
int m_C;
public:
int m_A;
};
//公有继承
class Son1 :public Base1
{
public:
int m_D;
};
void test01()
{
//父类中所有非静态的成员都会被子类继承
//父类的私有成员不可访问,但仍会被子类继承
cout <<"size of son: "<<sizeof(Son1) <<endl;
}
int main()
{
test01();
return 0;
}