484 Day 14
53:
54: class Horse : public Mammal
55: {
56: public:
57: Horse(int age, COLOR color ):
58: Mammal(age), itsColor(color)
59: { cout << “Horse constructor...\n”; }
60: virtual ~Horse() { cout << “Horse destructor...\n”; }
61: virtual void Speak()const { cout << “Whinny!... \n”; }
62: virtual COLOR GetItsColor() const { return itsColor; }
63: virtual void Sleep() const
64: { cout << “Horse snoring...\n”; }
65: virtual void Eat() const { cout << “Horse feeding...\n”; }
66: virtual void Move() const { cout << “Horse running...\n”;}
67:
68: protected:
69: COLOR itsColor;
70: };
71:
72: class Dog : public Mammal
73: {
74: public:
75: Dog(int age, COLOR color ):
76: Mammal(age), itsColor(color)
77: { cout << “Dog constructor...\n”; }
78: virtual ~Dog() { cout << “Dog destructor...\n”; }
79: virtual void Speak()const { cout << “Whoof!... \n”; }
80: virtual void Sleep() const { cout << “Dog snoring...\n”; }
81: virtual void Eat() const { cout << “Dog eating...\n”; }
82: virtual void Move() const { cout << “Dog running...\n”; }
83: virtual void Reproduce() const
84: { cout << “Dogs reproducing...\n”; }
85:
86: protected:
87: COLOR itsColor;
88: };
89:
90: int main()
91: {
92: Animal *pAnimal=0;
93: int choice;
94: bool fQuit = false;
95:
96: while (fQuit == false)
97: {
98: cout << “(1)Dog (2)Horse (3)Fish (0)Quit: “;
99: cin >> choice;
100:
LISTING14.10 continued