Search code examples
c++multiple-inheritancediamond-problem

Diamond problem with interfaces


I am using many abstract classes which define only pure virtual functions plus a virtual (non pure) destructor.

Is it still ok to have a diamond inheritance structure without using virtual inheritance? (I'd like to make sure that there are no problems even if some programmer does not know he should use virtual inheritance.) What's a good resource which gives a short but complete overview of this topic?

Thanks!


Solution

  • You can't. Without virtual inheritance, the inheritance graph just isn't a diamond. If Derived inherits from Left and Right, and both derive non-virtually from Base, then there will be two Base subobjects per Derived object.