Overview
Chapter 11 discusses additional techniques of programming with classes. Classes
provide reusability through their various relationships with each other. In this chapter,
students are introduced to two means of relating classes: inheritance (an “is–a”
relationship) and composition (a “has–a” relationship). They will also learn about the
three basic principles of object-oriented design: encapsulation, inheritance, and
polymorphism.
Objectives
In this chapter, the student will:
• Learn about inheritance
• Learn about derived and base classes
• Explore how to redefine the member functions of a base class
• Examine how the constructors of base and derived classes work
• Learn how the destructors of base and derived classes work
• Learn how to construct the header file of a derived class
• Become aware of stream classes hierarchy
• Explore three types of inheritance: public, protected, and private
• Learn about composition (aggregation)
• Become familiar with the three basic principles of object-oriented design
Teaching Tips
Inheritance
1. Explain why programmers might choose to extend a class definition when designing a
new class, rather than write one from scratch.
Inheritance is one of the primary aspects of OOD; therefore, you might want to
provide some additional real-world examples before continuing the discussion of
this section. For example, demonstrate how a transportation class can be a base
class from which many different modes might be derived, such as a bike, car, or
plane.