++


         

- 2


{}

virtual ~ZooAnimal();

virtual ostream& print( ostream& ) const;

string name() const { return _name; }

string family_name() const { return _fam_name; }

// ...

protected:

bool _onExhibit;

string _name;

string _fam_name;

// ...

};

virtual. , , Bear:

class Bear : public virtual ZooAnimal {

public:

enum DanceType {

two_left_feet, macarena, fandango, waltz };

Bear( string name, bool onExhibit=true )

: ZooAnimal( name, onExhibit, "Bear" ),

_dance( two_left_feet )

{}

virtual ostream& print( ostream& ) const;

void dance( DanceType );

// ...

protected:

DanceType _dance;

// ...

};

Raccoon:

class Raccoon : public virtual ZooAnimal {

public:

Raccoon( string name, bool onExhibit=true )

: ZooAnimal( name, onExhibit, "Raccoon" ),

_pettable( false )

{}

virtual ostream& print( ostream& ) const;

bool pettable() const { return _pettable; }

void pettable( bool petval ) { _pettable = petval; }

// ...

protected:

bool _pettable;

// ...

};