C Primer Plus (5th Edition)

   

Chapter 17. INHERITANCE PART II: abstract FUNCTIONS, POLYMORPHISM, and INTERFACES

You will learn about the following in this chapter:

Not only does inheritance allow us to arrange our classes in neat taxonomical hierarchies and to reuse the code of these classes effectively, as shown in Chapter 16, "Inheritance Part I: Basic Concepts," it also allows us to implement a powerful concept called polymorphism. When polymorphism is applied on a class hierarchy, it involves one ancestor class and several of its descendant classes. However, sometimes we want to apply polymorphism to a group of classes that do not have a common ancestor. Interfaces presented later in this chapter help us to break free from the class hierarchy structure and apply polymorphism to groups of classes without common ancestors.

Before we look at polymorphism, we need to introduce abstract functions that play an important role for implementing polymorphism in class hierarchies.


   

Категории