-
Book Overview & Buying
-
Table Of Contents
Deciphering Object-Oriented Programming with C++ [WARNING: NOT FOR USE IN OTHER MATERIAL/SEE CONTRACT]
By :
We’ve seen in Chapter 7, Utilizing Dynamic Binding through Polymorphism, that it is reasonable at times to group related derived class instances in a collection that is stored using base class pointers. Doing so allows uniform processing of related derived class types using polymorphic operations as specified by the base class. We also know that when a polymorphic base class operation is invoked, the correct derived class method will be invoked at runtime by virtue of the virtual functions and internal v-table that implement polymorphism in C++.
You may contemplate, however, whether it is possible to collect a group of related derived class types by a base class type that is an abstract class. Remember, an abstract class is not instantiable, so how might we store a derived class object as an object that cannot be instantiated? The solution is to use pointers (or even a reference). Whereas we cannot collect derived class...