Question #213004

Define a class Employee with data members as empno, name and designation. Derive a class Qualification from Employee that has data members UG, PG and experience. Create another class Salary which is derived from both these classes to display the details of the employee and compute their increments based on their experience and qualifications.

Expert's answer

#include <iostream>
#include <string>


using namespace std;




class Employee{
protected:
	string empno; 
	string name;
	string designation;
public:
	void get()
	{
		cout<<"Enter Employee No: ";
		getline(cin,empno);
		cout<<"Enter Employee Name: ";
		getline(cin,name);
		cout<<"Enter Employee Designation: ";
		getline(cin,designation);
	}
};
class Qualification :public Employee{
protected:
	int UG;
	int PG;
	int experience;
public:
	void get()
	{
		Employee::get();
		cout<<"Enter Employee UG: ";
		cin>>UG;
		cout<<"Enter Employee PG: ";
		cin>>PG;
		cout<<"Enter Employee Experience: ";
		cin>>experience;
	}
};
class Salary:public Qualification{
public:
	void get()
	{
		Qualification::get();
	}
	void displayDetailsEmployee(){
		cout<<"Employee No: "<<empno<<"\n";
		cout<<"Employee Name: "<<name<<"\n";
		cout<<"Employee Designation: "<<designation<<"\n";
		cout<<"Employee UG: "<<UG<<"\n";
		cout<<"Employee PG: "<<PG<<"\n";
		cout<<"Employee Experience: "<<experience<<"\n";
		int increments =UG+PG+experience;
		cout<<"Employee increments: "<<increments <<"\n";
		
	}
};




int main () {


	Salary salaryEmp;
	salaryEmp.get();
	salaryEmp.displayDetailsEmployee();
	//Delay
	system("pause");
	return 0;
}









LATEST TUTORIALS
APPROVED BY CLIENTS