#include <iostream>
using namespace std;
class Father{
int age;
char name[10];
public:
void get();
void show();
};
void Father::get(){
cout<<"Father Name Please: "<<endl;
cin>>name;
cout<<"Father Age Please: "<<endl;
cin>>age;
}
void Father::show(){
cout<<"Father name is: "<<name<<endl;
cout<<"Father Age is: "<<age<<endl;
}
class Mother{
int age;
char name[10];
public:
void get();
void show();
};
void Mother::get(){
cout<<"Mother name Please: "<<endl;
cin>>name;
cout<<"Mother Age Please: "<<endl;
cin>>age;
}
void Mother::show(){
cout<<"Mother Name is: "<<name<<endl;
cout<<"Mother Age is: "<<age<<endl;
}
class Son: public Father, public Mother{
int age;
char name[10];
public:
void get();
void show();
};
void Son::get(){
Father::get();
Mother::get();
cout<<"Son name Please: "<<endl;
cin>>name;
cout<<"Son Age Please: "<<endl;
cin>>age;
}
void Son::show(){
Father::show();
Mother::show();
cout<<"Son name is: "<<name<<endl;
cout<<"Son Age is: "<<age<<endl;
}
int main() {
Son s;
s.get();
s.show();
return 0;
}
//OUTPUT:
Father Name Please:
Abdi
Father Age Please:
54
Mother name Please:
Qamar
Mother Age Please:
37
Son name Please:
Moahmed
Son Age Please:
23
Father name is: Abdi
Father Age is: 54
Mother Name is: Qamar
Mother Age is: 37
Son name is: Moahmed
Son Age is: 23
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter