Page 190 - DCAP404 _Object Oriented Programming
P. 190
Unit 9: Inheritance
} Notes
class daughter : public father //derived class 2.
{
char name [15];
int age;
public:
void get ( )
{
father : : get ( );
cout << “your (daughter’s) name please In”
cin>>name;
cout << “your age please In”; cin >>age;
}
void show ( )
{
father : : show ( );
cout << “in my father name is: “ << name << “
In and his age is : “<<age;
}
};
main ( )
{
clrscr ( );
son S1;
daughter d1;
S1.get( );
D1.get( );
S1.show( );
D1.show( );
}
9.2.5 Hybrid Inheritance
There could be situations where we need to apply two or more types of inheritance to design a
program. Basically Hybrid Inheritance is the combination of one or more types of the inheritance.
Here is one implementation of hybrid inheritance.
//Program to show the simple hybrid inheritance
# include < isostream.h>
# include < conio.h>
class student //base class declaration
{
LOVELY PROFESSIONAL UNIVERSITY 183