6.8 Accidental DAG Multiple Inheritance via Poor Implementation of Optional Containment
Poor object-oriented designers who accidentally implement classes with more than one optional component using inheritance will find themselves with a bad case of DAG multiple inheritance. The House class from the previous chapter (Section 5.18) was defined with four optional data members, a heating system, a cooling system, a plumbing system, and an electrical system. If a designer tries to capture these optional data members in an inheritance hierarchy, then he or she will find themselves in trouble (see Figure 6.10).
Figure 6.10. A bad house.
Of course, all of this is unnecessary. The actual solution is to use containment by reference to implement optional data members. (See Chapter 5, Section 5.18, for a description of this solution.)