Objectives
In this chapter you’ll:
• Learn how polymorphism makes programming more convenient and systems more extensible.
• Learn the distinction between abstract and concrete classes and how to create abstract classes.
• Use runtime type information (RTTI).
• Learn how C++ implements virtual
functions and dynamic binding.
• Understand how virtual
destructors ensure that all appropriate destructors run on an object.
12.2 Introduction to Polymorphism: Polymorphic Video Game
12.3 Relationships Among Objects in an Inheritance Hierarchy
12.3.1 Invoking Base-Class Functions from Derived-Class Objects
12.3.2 Aiming Derived-Class Pointers at Base-Class Objects
12.3.3 Derived-Class Member-Function Calls via Base-Class Pointers
12.3.4 Virtual Functions and Virtual Destructors
12.4 Type Fields and switch
Statements
12.5 Abstract Classes and Pure virtual
Functions
12.6 Case Study: Payroll System Using Polymorphism
12.6.1 Creating Abstract Base Class Employee
12.6.2 Creating Concrete Derived Class SalariedEmployee
12.6.3 Creating Concrete Derived Class CommissionEmployee
12.6.4 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
12.6.5 Demonstrating Polymorphic Processing
12.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
3.144.109.34