#include
using std::cout;
using std::cin;
using std::endl;
class Horse
{
public:
Horse() { cout << "Horse constructor... "; }
virtual ~Horse() { cout << "Horse destructor... "; }
virtual void Whinny() const { cout << "Whinny!... "; }
private:
int itsAge;
};
class Bird
{
public:
Bird() { cout << "Bird constructor... "; }
virtual ~Bird() { cout << "Bird destructor... "; }
virtual void Chirp() const { cout << "Chirp... "; }
virtual void Fly() const
{
cout << "fly! ";
}
private:
int itsWeight;
};
class Pegasus : public Horse, public Bird
{
public:
void Chirp() const { Whinny(); }
Pegasus() { cout << "Pegasus constructor... "; }
~Pegasus() { cout << "Pegasus destructor... "; }
};
const int MagicNumber = 2;
int main(){
Horse* Ranch[MagicNumber];
Bird* Aviary[MagicNumber];
Horse * pHorse;
Bird * pBird;
pHorse = new Pegasus;
pHorse = new Horse;
Ranch[0] = pHorse;
pBird = new Pegasus;
pBird = new Bird;
Aviary[0] = pBird;
Ranch[0]->Whinny();
delete Ranch[0];
Aviary[0]->Chirp();
Aviary[0]->Fly();
delete Aviary[0];
return 0;
}