Chapter 14

An Overviewof Multiple Inheritance

[The] insane rootThat takes the reason prisoner

—William Shakespeare:Macbeth (1606)

This chapter and the next two explain what happens to our inheritance model when multiple inheritance is taken into account. In fact, it turns out that IM Prescriptions 1-20 as defined and discussed in Part II need no revision or reformulation at all, although some of them do have implications that aren’t always immediately obvious, and one in particular—number 8, on common subtypes and supertypes—needs especially careful discussion. I’ll deal with that one in the next chapter. In this chapter, by contrast, I just want to lay some general groundwork.

As you know, single inheritance means every proper subtype has exactly one immediate supertype, from which it inherits operators and constraints; by contrast, multiple inheritance means a proper subtype can have several immediate supertypes, and it inherits operators and constraints from all of them. Fig. 14.1, a repeat of Fig. 13.1 from Chapter 13, shows a simple example. Note in particular that type SQUARE in that figure has two immediate supertypes, and hence that the example is indeed an example of multiple inheritance as such.


Fig. 14.1 (same as Fig. 13.1): Example of a type graph

Fig. 14.1 will serve as the basis for discussions and explanations throughout this part of the book. First, however, I need ...

Get Type Inheritance and Relational Theory now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.