posted 25 years ago
Multiple inheritance is useful when a new class wants to combine multiple contracts and inherit some, or all, of the implementation of those contracts. but when there is more than one superclass, problem arise when a superclass's behaviour is inherited in two ways. Assume, for a moment, the following type tree:
X estends W
Y extends W
Z extends X
Z extends Y
This is commonly called diamond inheritance, and there is nothing worng with it. many legitimate designs show this structure. The problems exist in the inheritance of implementation, where W's implementation stores some state. If class W had, for example, a public field named gogging, and if you had a reference to an object of type Z called zref, what zref.goggin refer to ? It might refer to X's copy of goggin, or it might refer to Y's copy, or X and Y might share a single copy of goggin because Z really only a W once even thought it is both and a Y.
Resolving such issues is non-trivial and complicates the design and use of class hierarchies. To avoid such issues, the Java programming language uses the single inheritance model of OOP.