Page 186 - DCAP404 _Object Oriented Programming
P. 186
Unit 9: Inheritance
cout << “Enter the age”; Notes
cin >> age;
}
void father : : show ( )
{
cout<< “In my father’s name is:”<<name<< “In my father’s age
is: <<age;
}
class mother //Declaration of base class 2
{
char name [20];
int age;
public:
void get ( )
{
cout << “mother’s name please” << “In”;
cin >> name;
cout << “mother’s age please” << “in”;
cin >> age;
}
void show ( )
{
cout << “In my mother’s name is: “<<name;
cout << “In my mother’s age is: “<<age;
class daughter : public father, public mother //derived class:
inheriting
{ //publicly
char name [20]; //the features of both the base class
int std;
public:
void get ( );
void show ( );
};
void daughter :: get ( )
{
father :: get ( );
mother :: get ( );
cout << “child’s name: “;
cin >> name;
cout << “child’s standard”;
LOVELY PROFESSIONAL UNIVERSITY 179