Hybrid Inheritance - sample program

/* $ Hybird Inheritance with Employee details $ */
#include
using namespace std;
class emp
{
int eno;
char ename[20];
public:
void getdata()
{
cout<<"\nEnter the Employee number : ";
cin>>eno;
cout<<"\nEnter the employee Name : ";
cin>>ename;
}
void display()
{
cout<<"\nEmployee Number : "<cout<<"\nEmployee Name : "<}
};
class ebasic:public emp
{
public:
float bpay;
char degn[20];
void getdata1()
{
cout<<"\nEnter the designation : ";
cin>>degn;
cout<<"Enter the Basic pay : ";
cin>>bpay;
}
void display1()
{
cout<<"\nEmployee Designation : "<cout<<"Employee Basic Pay : "<}
};
class epers
{
char addr[50],cname[20];
//int age;
public:
void getdata2()
{
cout<<"\nEnter the Name of the company : ";
cin>>cname;
cout<<"\nEnter the address of the company..."<cin>>addr;
}
void display2()
{
cout<<"\nCompany Name : "<cout<<"Company address : "<}
};
class edetail:public epers,public ebasic
{
float sal,hra,da;
public:
void calc()
{
hra=(bpay*0.4);
da=(bpay*0.75);
sal=bpay+hra+da;
}
void display3()
{
cout<<"Basic Pay : "<cout<<"H.R.A : "<cout<<" D.A : "<cout<<" Salary : "<}
};
main()
{
edetail ed;
ed.getdata();
ed.getdata1();
ed.getdata2();
ed.calc();
ed.display();
ed.display1();
ed.display2();
ed.display3();
}

No comments: