//tq.h
//Example of simple inheritance
//base class
class Reptile
{
public:
Reptile();
~Reptile();
void setHeight(int height) { itsHeight = height;}
int getHeight() {return itsHeight;}
void SetWeight(int weight) { itsWeight = weight;}
int getWeight() { return itsWeight;}
protected:
int itsHeight;
int itsWeight;
};
//Constructor
Reptile::Reptile()
{
cout <<"Calling Base Class constructor(Reptile)....nn";
}
//Destructor
Reptile::~Reptile ()
{
cout <<"Calling Base Class destructor(Reptile)....n";
}
//superste, derived class from base class(reptile)
class Lizard: public Reptile
{
public:
Lizard();
~Lizard();
void setAge(int age) { itsAge = age;}
int getAge() { return itsAge;}
void RegenerateTale() const { cout<<"Regenerating Tale....n";}
void RunFromPredator() const { cout <<"Running...n";}
protected:
int itsAge;
};
//Constructor
Lizard::Lizard()
{
itsAge = 4;
cout <<"Calling Derived Class Constructor(Lizard)....nn";
}
Lizard::~Lizard()
{
cout <<"Calling Derived Class Destructor(Lizard)....n";
}