Chapter 12

Implications of Substitution

The introduction of inheritance and, in particular, the principle of substitution, has a subtle but pervasive impact on almost all aspects of a programming language. In this chapter, we will examine some of these effects, considering in detail the type system, the meaning of assignment, testing for equivalence, the creation of copies, and storage allocation.

We have described the is-a relationship as a fundamental property of inheritance. One way to view the is-a relationship is as a means of associating a type, as in a type of a variable, with a set of values—namely, the values the variable can legally hold. If a variable win is declared as an instance of a specific class— say, Window—certainly it should ...

Get An Introduction to Object-Oriented Programming, 3rd Edition 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.