#include <iostream> using namespace std; class A { public: int x, y; static int s; void f1() { } static void f2() { } virtual void f3() { } }; int A::s = 123; int main() { cout << "size = " << sizeof(A); return 0; }
#include <iostream> using namespace std; class A { public: int x, y; }; class B: public A { }; class C: virtual public A { }; int main() { cout << "class B size = " << sizeof(B) << endl; cout << "class C size = " << sizeof(C) << endl; return 0; }
原文:http://blog.csdn.net/nestler/article/details/26011041