请教一个c++对象大小的问题
class Base{ public: Base(){} virtual void foo() { cout << "Base::foo()\n"; } virtual void too() { cout << "Base::too()\n"; } int st; }; class Dervied :public Base { public: Dervied(){} virtual void foo() { cout << "Derived::foo()\n"; } virtual void too() { cout << "Derived::too()\n"; } int sm; private: int val; }; int main() { Base b;Dervied f; cout << sizeof(b) << endl;//8 cout << sizeof(f) << endl;//10 }
为什么dervied对象的大小是10呢? 是在vs13上运行的