#include <iostream>
using namespace std;
//Hierarchical inheritance
class Employee{
protected:
string name;
int employeeID;
public:
void inputEmployeeInfo(){
cout<<"Enter name: "<<endl;
cin>>name;
cout<<"Enter Employee ID: "<<endl;
cin>>employeeID;
}
void displayEmployeeInfo(){
cout<<"Name: "<<name<<endl;
cout<<"Employee ID: "<<employeeID<<endl;
}
};
//Derived Manager Class From Employee Class
class Manager :virtual public Employee{
protected:
int level;
public:
void inputManagerInfo(){
//inputEmployeeInfo();
cout<<"Enter Manager Level: "<<endl;
cin>>level;
}
void displayManagerInfo(){
//displayEmployeeInfo();
cout<<"Manager Level: "<<level<<endl;
}
};
//Derived Developer Class From Employee
class Developer : virtual public Employee{
protected:
int progLang;
public:
void inputDeveloperInfo(){
//inputEmployeeInfo();
cout<<"Enter Programing Language: "<<endl;
cin>>progLang;
}
void displayDeveloperInfo(){
//displayEmployeeInfo();
cout<<"Programing Language: "<<progLang<<endl;
}
};
//DErived class for Teamlead That will display both info manager and developer
class TeamLead : public Manager, public Developer{
public:
void inputInfo(){
inputEmployeeInfo(); // Employee Info
inputManagerInfo(); // Manager Info
inputDeveloperInfo(); //Developer Info
}
void displayInfo(){
cout<<"Team Lead Details: "<<endl;
displayEmployeeInfo(); // Employee Info
displayManagerInfo(); // Manager Info
displayDeveloperInfo(); //Developer Info
}
};
int main() {
TeamLead tl;
tl.inputInfo();
cout<<endl;
tl.displayInfo();
return 0;
}
//OUTPUT:
Enter name:
mohamed
Enter Employee ID:
1222
Enter Manager Level:
7
Enter Programing Language:
java
Team Lead Details:
Name: mohamed
Employee ID: 1222
Manager Level: 7
Programing Language: java
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter