Multiple Inheritance

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <iostream>

using namespace std;


/// Multiple Inheritance

class Employee
{
private:
int id;
string name;
public:
Employee(): id(0), name("n/a"){}
Employee(int i, string na): id(i), name(na){}
void getdata()
{
cout<<"Enter Id ";
cin>>id;
cout<<"Enter Name ";
cin>>name;
}
void showdata()
{
cout<<"Id "<<id<<endl;
cout<<"Name "<<name<<endl;
}
};

class Student
{
private:
string degree;
public:
Student(): degree("n/a"){}
Student(string de): degree(de){}
void getedu()
{
cout<<"Enter degree Title ";
cin>>degree;
}
void showedu()
{
cout<<"Degree "<<degree<<endl;
}
};
class Manager : private Employee, private Student
{
private:
float dues;
string jobtitle;
public:
Manager(): Employee(), Student(), dues(0.0f), jobtitle("n/a"){}
Manager(int i, string na, string de, float du, string title): Employee(i,
na), Student(de), dues(du), jobtitle(title){}
void getdata()
{
Employee::getdata();
Student::getedu();
cout<<"Enter Dues ";
cin>>dues;
cout<<"Enter Job Title ";
cin>>jobtitle;
}
void showdata()
{
Employee::showdata();
Student::showedu();
cout<<"Dues "<<dues<<endl;
cout<<"Job Title "<<jobtitle<<endl;
}
};

int main()
{
Manager m1;
m1.getdata();
m1.showdata();
return 0;
}

You might also like