466 Day 14
49: Bird(COLOR color, bool migrates, int age);
50: virtual ~Bird() {cout << “Bird destructor...\n”; }
51: virtual void Chirp()const { cout << “Chirp... “; }
52: virtual void Fly()const
53: { cout << “I can fly! I can fly! I can fly! “; }
54: virtual COLOR GetColor()const { return itsColor; }
55: virtual bool GetMigration() const { return itsMigration; }
56: protected:
57: COLOR itsColor;
58: bool itsMigration;
59: };
60:
61: Bird::Bird(COLOR color, bool migrates, int age):
62: Animal(age),
63: itsColor(color), itsMigration(migrates)
64: {
65: cout << “Bird constructor...\n”;
66: }
67:
68: class Pegasus : public Horse, public Bird
69: {
70: public:
71: void Chirp()const { Whinny(); }
72: Pegasus(COLOR, HANDS, bool, long, int);
73: virtual ~Pegasus() {cout << “Pegasus destructor...\n”;}
74: virtual long GetNumberBelievers() const
75: { return itsNumberBelievers; }
76: virtual COLOR GetColor()const { return Horse::itsColor; }
77: virtual int GetAge() const { return Horse::GetAge(); }
78: private:
79: long itsNumberBelievers;
80: };
81:
82: Pegasus::Pegasus(
83: COLOR aColor,
84: HANDS height,
85: bool migrates,
86: long NumBelieve,
87: int age):
88: Horse(aColor, height,age),
89: Bird(aColor, migrates,age),
90: itsNumberBelievers(NumBelieve)
91: {
92: cout << “Pegasus constructor...\n”;
93: }
94:
95: int main()
96: {
97: Pegasus *pPeg = new Pegasus(Red, 5, true, 10, 2);
LISTING14.5 continued