HOME

Sunday, November 29, 2015

MULTIPLE INHERITANCE

#include<iostream>
using namespace std;
class employee
{
protected:
    char name[20];
    int id;
public:
    void getdata()
    {
        cout<<"ENTER NAME AND ID"<<endl;
        cin>>name>>id;
    }
};
class salary
{
protected:
    float salaryy;
public:
    void getdata()
    {
        cout<<"ENTER SALARY"<<endl;
        cin>>salaryy;
    }
};
class bonus
{
protected:
    float bonuss;
public:
    void getdata()
{
    cout<<"ENTER BONUS AMOUNT"<<endl;
    cin>>bonuss;
}
};
class total: public employee, public salary, public bonus
{
    protected:
    int totall;
public:
    void getdata()
{
    totall=salaryy+bonuss;
        cout<<"NAME= "<<name<<endl;
    cout<<"ID = "<<id<<endl;
    cout<<"SALARY = "<<salaryy<<endl;
    cout<<"BONUS= "<<bonuss<<endl;
    cout<<"TOTAL SALARY= "<<totall<<endl;
}
};
int main()
{
    total s1;
    s1.employee::getdata();
    s1.salary::getdata();
    s1.bonus::getdata();
    s1.total::getdata();
    return 0;
}

No comments:

Post a Comment