TITLE: Constructor calls with virtual base classes PROBLEM: Could someone explain to me why the following program requires that "alpha" have a NULL constructor? I'm not calling the NULL constructor... class alpha { int x; public: alpha() : x(0) {} // the null constructor alpha(int a) : x(a) {} }; class beta : virtual public alpha { int y; public: beta(int a) : alpha(a), y(2) {} }; class gamma : virtual public alpha { int z; public: gamma(int a) : alpha(a), z(3) {} }; class zeta : public beta, public gamma { int w; public: zeta(int a, int b) : beta(a), gamma(b), w(4) {} }; RESPONSE: Steve Clamage (steve@taumet.com) When the most-derived class of a hierarchy is constructed, all virtual base classes are constructed before any of the direct base classes. Since you don't provide an initializer for alpha in the zeta header, the compiler will use the null constructor for alpha. Since you do provide a constructor for alpha, the compiler will not create the null constructor for you. You show your code with the null constructor defined; I assume the compiler complained when that line was omitted. One more point: In this example, a constructor for the alpha virtual base class is called once for zeta, again for beta, and a third time for gamma. In this case, the integer member is overwritten, which may or may not be what you want. If the alpha constructor did something with side effects, like open a file or allocate memory, that is NOT what you want. In such a case you have to take care that intermediate base classes do not have initializers for virtual base classes. That is, only the null constructor for the virtual base should be used, and used implicitly. The null constructor for the virtual base class does those things which should always be done (once) and which do not depend on any parmeters to the derived class constructors. You add an init() function to the virtual base class, and call it from within the other class constructors. (You may have to ensure it is only called once.) This all goes to show that mulitple inheritance is different in kind, not just in degree, from single inheritance.