class A { public: void *p1; private: void *p2; protected: void *p3; }; class B: public A {};那么sizeof(B)的数值是()
linux 32位下的结果,供大家参考: #include <stdio.h> class A { public: void *p1; int a; int b; private: void *p2; int c; int d; protected: void *p3; int e; int f; }; class B: public A {}; class C: private A {}; class D: protected A {}; int main() { int ret_public = sizeof(B); int ret_private = sizeof(C); int ret_protected = sizeof(D); printf("public_ret = %d\n", ret_public); printf("private_ret = %d\n", ret_private); printf("protected_ret = %d\n", ret_protected); return 0; }