C++ object size with virtual methods
问题 I have some questions about the object size with virtual. 1) virtual function class A { public: int a; virtual void v(); } The size of class A is 8bytes....one integer(4 bytes) plus one virtual pointer(4 bytes) It's clear! class B: public A{ public: int b; virtual void w(); } What's the size of class B? I tested using sizeof B, it prints 12 Does it mean that only one vptr is there even both of class B and class A have virtual function? Why there is only one vptr? class A { public: int a;