Skip to content

Lesson 6 Companion — Object References & Inheritance ​

1. Inheritance definition ​

SAP defines inheritance as a generalization-specialization relationship where subclasses adopt components from superclasses and can add or redefine behavior.

2. Constructor rule ​

Constructors are not redefined with REDEFINITION. A subclass declares its own instance constructor and calls super->constructor as required.

3. Static vs dynamic type ​

This distinction is the foundation of polymorphism:

text
reference says what interface is visible
object says what implementation actually exists

4. Prefer shallow inheritance ​

Deep inheritance hierarchies become difficult to reason about. Use inheritance for genuine “is-a” specialization, and prefer interfaces/composition when shared behavior does not require a family hierarchy.

SAP references ​