标签:style blog class code c ext
C++对象模型内存布局如下:#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; }
标签:style blog class code c ext
原文地址:http://blog.csdn.net/nestler/article/details/26011041