|
|
|
|
|
|
|
Hour 18
Advanced Polymorphism |
|
|
|
|
|
|
|
|
In the previous hours, you learned how to write virtual functions in derived classes. This is the fundamental building block of polymorphism: the capability to bind specific, derived class objects to base class pointers at runtime. Now you will learn |
|
|
|
|
|
|
|
|
· What casting down is and why you might want to do it |
|
|
|
|
|
|
|
|
· What abstract data types are |
|
|
|
|
|
|
|
|
· What pure virtual functions are |
|
|
|
|
|
|
|
|
Problems with Single Inheritance |
|
|
|
|
|
|
|
|
In the previous chapters, I discussed treating derived objects polymorphically with their base classes. You saw that if the base class has a method Speak() that is overridden in the derived class, a pointer to a base object that is assigned to a derived object will do the right thing. Listing 18.1 illustrates this idea. |
|
|
|
|
|