TITLE: Virtual inheritance and the open-closed principle PROBLEM: A <-- base class / \ / \ B C \ / \ / C <-- derived class RESPONSE: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON), 18 Jun 93 [...] although any D is-a C, and any C is-an A, it is not the case that any D is-an A: in fact, any D is actually *two* As. Thus non-virtual inheritance doesn't correctly model sub-typing. If sub-typing is incorrectly modelled, then there is no way that identity can be correctly modelled. RESPONSE: maxtal@physics.su.OZ.AU (John Max Skaller) That was one of the major conclusions reached by Markku Sakkinen. (Sakkinen proposed that the 'default' modes of inhertance be virtual for public inheritance, and non-virtual for private inheritance) It is why I have been questioning use of 'ordinary' public inheritance: it doesn't model 'isA' relations, and doesnt represent subclassing (in general). When it does, it usually does so by breaking the open-ness part of the open/closed principle (it only works if the programmer does not derive further classes). It is why I recommend that, almost always for abstract classes, derivation should be virtual. [ The open/closed principle was espoused by Meyer in "Object-Oriented Software Construction". It basically states that a class should not have to be modified (it is closed) in order to extend it by subclassing (openness). This is a worthwhile rule-of-thumb to use in designing classes. -adc ]