C++ 继承(二)——继承中的对象模型

tech2026-02-21  2

继承中已经完整基层父类内容,但是私有成员编译器隐藏,不可访问。

#include <iostream> using namespace std; class Base { public: int m_A; protected: int m_B; private: int m_C; }; class Son1:public Base { public: int m_D; }; void test01() { Son1 s1; cout<< sizeof(s1)<<endl; } int main() { test01(); return 0; }

最新回复(0)