Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- class base1
- {
- protected:
- char name[20];
- char dob[20];
- char bg[5];
- public:
- base1()
- {
- }
- base1(char *x1,char *x2,char *x3)
- {
- strcpy(name,x1);
- strcpy(dob,x2);
- strcpy(bg,x3);
- }
- void BASE1()
- {
- cout<<"\nname: "<<name;
- cout<<"\ndate of birth: "<<dob;
- cout<<"\nblood group: "<<bg;
- }
- };
- class base2
- {
- protected:
- float height;
- float weight;
- public:
- base2()
- {
- }
- base2(float x4,float x5)
- {
- height=x4;
- weight=x5;
- }
- void BASE2()
- {
- cout<<"\nheight: "<<height;
- cout<<"\nweight: "<<weight;
- }
- };
- class base3
- {
- protected:
- int pno;
- char *add;
- public:
- base3()
- {
- }
- base3(int x6,char *x7)
- {
- pno=x6;
- strcpy(add,x7);
- }
- void BASE3()
- {
- cout<<"\npolicy number: "<<pno;
- cout<<"\naddress details: "<<add;
- }
- };
- class derived:public base1,public base2,public base3
- {
- int phoneno;
- int drivingno;
- public:
- derived()
- {
- }
- derived(char *x1,char *x2,char *x3,float x4,float x5,int x6,char *x7,int x8,int x9):base1(x1,x2,x3),base2(x4,x5),base3(x6,x7)
- {
- phoneno=x8;
- drivingno=x9;
- }
- void display()
- {
- BASE1();
- BASE2();
- BASE3();
- cout<<"\nphone number:"<<phoneno;
- cout<<"\ndriving number:"<<drivingno;
- }
- };
- int main()
- {
- derived *d;
- int i,n,y=1,x,phoneno,drivingno,pno;
- float height,weight;
- char name[100],bg[100],dob[100],add[100];
- while(y)
- {
- cout<<"Enter your choice: ";
- cout<<"\n1.Enter details\n2.show details\n3.exit\n";
- cin>>x;
- switch(x)
- {
- case 1:
- cout<<"\n---------EMPLOYEE---------\n";
- cout<<"\nEnter the name of the employee: ";
- cin>>name;
- cout<<"\nEnter the date of birth: ";
- cin>>dob;
- cout<<"\nEnter the blood group: ";
- cin>>bg;
- cout<<"\nEnter the height of the employee: ";
- cin>>height;
- cout<<"\nEnter the weight of the employee: ";
- cin>>weight;
- cout<<"\nEnter the policy number: ";
- cin>>pno;
- cout<<"\nEnter the address details: ";
- cin>>add;
- cout<<"\nEnter phone number: ";
- cin>>phoneno;
- cout<<"\nEnter driving license number: ";
- cin>>drivingno;
- d=new derived(name,dob,bg,height,weight,pno,add,phoneno,drivingno);
- break;
- case 2:
- cout<<"\nEmployee details:\n";
- d->display();
- break;
- case 3:exit(0);
- break;
- }
- cout<<"for continue.....press<1> or press<0>\n";
- cin>>y;
- }
- }
Add Comment
Please, Sign In to add comment