TITLE: virtual inheritance with common ancestry (Newsgroups: comp.lang.c++.moderated, 17 Sep 96) PROBLEM: herbs@cntc.com (Herb Sutter) If B requires a particular base constructor, then it should probably not derive virtually from that base. Consider a related example: A / \ v/ \v B1 B2 \ / \ / C Now if B1 requires a particular A ctor, and B2 also requires a particular (but different) A ctor, then clearly at least one is going to lose. If this breaks B1 or B2, then I'd suggest the model is flawed: by definition this design does not allow them to share the same base part, so they probably should be using normal inheritance. However, if both B1 and B2 should share a common A part, that's fine; they just shouldn't depend on a particular construction. They can (if A has no default ctor, they must) specify a base constructor for when they are used as B1 or B2 objects, but just can't depend on that particular construction if they are used as further-derived (e.g., C) objects. RESPONSE: clamage@taumet.Eng.Sun.COM (Steve Clamage) Nice example. Let me take the discussion one step further. If you derive from a concrete class, you often make a lot of problems. If you derive virtually from a concrete class, you almost always make problems. If a virtual base class has data, the compiler- defined assignment operator may not do the right thing, and writing your own is extremely difficult. Tom Cargill in "C++ Programming Style" devotes 7 pages to the problem of assignment operators in the presence of general virtual base classes, and concludes there is no general solution. Thus, many C++ experts recommend that a class used as a virtual base class have no user-defined constructors at all, and no data either. The virtual base class in effect just defines an interface, and has only pure virtual member functions. Following that convention eliminates the problems of how to initialize or assign objects.