#include<iostream>using namespace std;#include<string>//继承中的对象模型class Base {public:int m_A;protected:int m_B;private:int m_C;};class son:public Base {//公有继承public:int m_D;};void test() {//son的大小为16//父类中所有的非静态成员都会被子类继承下去//父类中私有成员属性是被编译器隐藏了,因此访问不到,但确实是被继承下去了cout << "sizeof(son)= " << sizeof(son) << endl;}int main() {test();return 0;}
父类中所有的非静态成员都会被子类继承下去
父类中私有成员属性是被编译器隐藏了,因此访问不到,但确实是被继承下去了
