Page 193 - DCAP404 _Object Oriented Programming
P. 193
Object-oriented Programming
Notes 9. A direct base class is a base class that appears directly as a ……………………. in the
declaration of its derived class.
10. ………………………… inheritance is the combination of types of inheritance.
9.3 Ambiguity in Multiple and Multipath Inheritance
9.3.1 Ambiguity in Multiple Inheritance
#include <iostream>
using namespace std;
typedef int HANDS;
enum COLOR { Red, Green, Blue, Yellow, White, Black, Brown } ;
class Animal
{
public:
Animal(int);
virtual ~Animal() { cout << "Animal destructor...\n"; }
virtual int GetAge() const { return itsAge; }
virtual void SetAge(int age) { itsAge = age; }
private:
int itsAge;
};
Animal::Animal(int age):
itsAge(age)
{
cout << "Animal constructor...\n";
}
class Horse : public Animal
{
public:
Horse(COLOR color, HANDS height, int age);
virtual ~Horse() { cout << "Horse destructor...\n"; }
virtual void Whinny()const { cout << "Whinny!... "; }
virtual HANDS GetHeight() const { return itsHeight; }
186 LOVELY PROFESSIONAL UNIVERSITY