April 2011
Beginner
464 pages
9h 18m
English
In the previous hours, we discussed treating derived objects polymorphically with their base classes. You saw that if the base class has a member function 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. The Mammal12 program in Listing 18.1 illustrates this idea.
Listing 18.1 The Full Text of Mammal12.cpp
1: #include <iostream> 2: 3: class Mammal 4: { 5: public: 6: Mammal():age(1) { std::cout << "Mammal constructor ...\n"; ...