C++ Program (Family
Details Using Hybrid Inheritance)
#include<iostream.h>
#include<conio.h>
class
gffamily
{
protected:
char gf[30],gm[30];
public:
void get()
{
cout<<"\t FAMILY DETAILS\n ";
cout<<"\t ~~~~~~ ~~~~~~~\n ";
cout<<"Grand Father Name :";
cin>>gf;
cout<<" Grand Mother Name :";
cin>>gm;
}
};
class
ffamily: public gffamily
{
protected:
char fa[30],mo[30];
public:
void getf()
{
cout<<" Father Name :";
cin>>fa;
cout<<" Mother Name :";
cin>>mo;
}
};
class chi
{
protected:
int i,n;
char name[15][25];
public:
void getc()
{
cout<<" Enter the Number of
Child:";
cin>>n;
cout<<"\n Child Name :
";
for(int i=0;i<n;i++)
{
cin>>name[i];
}
}
};
class
chil:public chi,public ffamily
{
public :
void display()
{
cout<<"\n";
cout<<"\t\t FAMILY DETAILS\n ";
cout<<"\t\t ~~~~~~ ~~~~~~~\n ";
cout<<"\n";
cout<<"Grand Father Name :"<<gf<<endl;
cout<<"Grand Mother Name :"<<gm<<endl;
cout<<"Father Name
:"<<fa<<endl;
cout<<"Mother Name :"<<mo<<endl;
cout<<"Number of Child
:"<<n<<endl;
for(i=0;i<n;i++)
{
cout<<"\n Child Name
:"<<name[i];
}
}
};
void
main()
{
chil s;
clrscr();
s.get();
s.getf();
s.getc();
s.display();
getch();
}
output please
ReplyDelete