Friday, December 3, 2010

Class Size

class IVAC : public virtual IA {int i;}; is 12 bytes on Solaris.

There are two integers and one vptr. Since IA is being used as virtual base for IVAC. It's integer will be shared and not replicated by any of the subclasses. A strange thing with virtual

bases, is that their constructor is called from the most derived subclass. This means if you deepen the class hierachy under a virtual base, the new furthest derived class will be

responsible for properly initializing the virtual base class. This can be a point of instability in the system.

No comments:

Post a Comment