Chapter 7. Polymorphism
Along with data abstraction, inheritance and polymorphism form the basic set of tools necessary for object-oriented programming. The implementation of polymorphism in C++ is efficient and flexible but complex.
In this chapter, we'll see how the flexibility offered by C++'s implementation of polymorphism is often abused, and we'll offer guidelines for taming its complexity. Along the way, we'll examine how inheritance and virtual functions are implemented and how that implementation reflects in turn on the C++ language itself.
Gotcha #69: Type Codes
One of the surest signs of “my first C++ program” is the presence of a type code as a class data member. (I used them in my first C++ program, and they caused me no end of ...