Overriding

Now, overriding is a slightly different concept, albeit a related one. Overriding occurs when a child class changes the meaning of a function originally defined in the parent class. Thus, overriding specifically requires a child-class, parent-class relationship.

Different child classes can override the same function in the parent class is different ways.

Alternatively, the parent class can have some default behavior, which only some child classes override, while others leave the default as is.

Because code can be inherited from the parent classes, this contributes to code sharing.

Because even if they override a function they must use the same interface, the idea of overriding ensures common interfaces among a family of different components.

[audio] [real] Text to accompany slide10, in Chapter 14 of An Introduction to Object-Oriented Programming