The compiler creates virtual table for the base class and also for the derived class whether we override it or not.
That means each class has separate virtual table. when we get the size of the each class with out any data members...
the size of base is -- 4 bytes(64 bit)
and the size of derived is -- 1
The size of base class 4 is correct since it creates the virtual pointer internally and its size is member data + virtual pointer, but it in this case I have included any data members so it has given 4 byts.
But why in case of derived is 1 byte, since it the derived class has overridden the virtual function from base, this will also contains the virtual pointer which will be pointing to derived class Vtable, it the size of the class suppose to be 4 instead of 1 byte.
virtual void display()
int _tmain(int argc, _TCHAR* argv)
why derived class size is 1( it is suppose to be 4)?