C++ program to display employee information using multiple inheritance

#include<iostream.h>
#include<conio.h>
class basic
{
protected:
char name[20];
int empid;
char gender[10];
public:
void getBasicInfo(void)
{
cout << "Enter Your Name: ";
cin.getline(name,20);
cout << "Enter Your Employee ID: "; cin >> empid;
cout << "Enter Your Gender: "; cin >> gender;
}
};
class dept
{
protected:
char deptname[20];
char assignwork[20];
int time;
public:
void getDeptInfo(void)
{
cout << "Enter Your Department Name: "; cin >> deptname;
cout << "Enter assigned work: "; cin >> assignwork;
cout << "Enter time in hours to complete work: "; cin >> time;
}
};
class employee: private basic, private dept
{
public:
void getEmployeeInfo(void){
cout << "Enter employee's basic info: "<< endl;
getBasicInfo();
cout << "Enter employee's department info: "<< endl;
getDeptInfo();
}
void printEmployeeInfo(void)
{
cout << "***** Basic Information of Employee *****"<< endl;
cout << "Name: " << name << endl;
cout << "Employee ID: " << empid << endl;
cout << "Gender: " << gender << endl << endl;
cout << "***** Department Information *****" << endl;
cout << "Department Name: " << deptname << endl;
cout << "Assigned Work: " << assignwork << endl;
cout << "Time to complete work: " << time<< endl;
}
};
void main()
{
employee emp;
emp.getEmployeeInfo();
emp.printEmployeeInfo();
getch();
}

 

Output:

C++ program to display employee information using multiple inheritance

Leave a Reply

Your email address will not be published. Required fields are marked *