Single Inheritance

Program:


    #include<iostream.h>
    #include<conio.h>
    #include<stdio.h> 
class pers { public: char name[30],bloodg[10],dob[10]; public: void get(void); void show(void); }; class pers1 { public: char height[10],weight[10]; public: void get1(void); void show1(void); }; class pers2 { public: long int ino; char add[20]; public: void get2(void); void show2(void); }; class pers3 { public: long int tno; char dlno[20]; public: void get3(void); void show3(void); }; void pers::get(void) { cout<<"\n\n Enter the Name: "; cin>>name; cout<<"\n\n Enter DOB: "; cin>>dob; cout<<"\n\n Enter the Blood Group: "; cin>>bloodg; } void pers::show(void) { cout<<"\n\n Name: "<<name; cout<<"\n\n Date of Birth: "<<dob; cout<<"\n\n Blood Group: "<<bloodg; } void pers1::get1(void) { cout<<"\n\n Enter the Height: "; cin>>height; cout<<"\n\n Enter Weight: "; cin>>weight; } void pers1::show1(void) { cout<<"\n\n Weight: "<<weight; cout<<"\n\n Height: "<<height; } void pers2::get2(void) { cout<<"\n\n Enter the Insurance Number: cin>>ino; cout<<"\n\n Enter Contact address: "; cin>>add; } void pers2::show2(void) { cout<<"\n\n Insurance Number: "<<ino; cout<<"\n\n Contact address: "<<add; } void pers3::get3(void) { cout<<"\n\n Enter the Telephone number: "; cin>>tno; cout<<"\n\n Enter driving licence number: "; cin>>dlno; } void pers3::show3(void) { cout<<"\n\n Telephone Number: "<<tno; cout<<"\n\n Driving licence Number: "<<dlno; } void main() { char a; x: clrscr(); pers p; pers1 p1; pers2 p2; pers3 p3; p.get(); p1.get1(); p2.get2(); p3.get3(); cout<<"\n\n\n\t Personal Information System"; cout<<"\n\t ***************************"; cout<<endl; p.show(); p1.show1(); p2.show2(); p3.show3(); cout<<"\n\n Do u want to continue [y/n]"; cin>>a; if(a=='y'||a=='Y') goto x; getch(); }
Powered by nasrullah.in - TechnoNasr 2003-2020.
Designed & Developed by Mohamed Nasrullah.M