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.
#include <iostream>
#include <string>
using namespace std;
class Employee{
protected:
string empno;
string name;
string designation;
public:
void input()
{
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 input_qualification()
{
input();
cout<<"Enter Employee UG: ";
cin>>UG;
cout<<"Enter Employee PG: ";
cin>>PG;
cout<<"Enter Employee Experience: ";
cin>>experience;
}
};
class Salary:public Qualification{
private:
int increments;
public:
void input_salary()
{
input_qualification();
increments=UG+PG+experience;
}
void display(){
cout<<"No: "<<empno<<"\n";
cout<<"Name: "<<name<<"\n";
cout<<"Designation: "<<designation<<"\n";
cout<<"UG: "<<UG<<"\n";
cout<<"PG: "<<PG<<"\n";
cout<<"Experience: "<<experience<<"\n";
cout<<"Increments: "<<increments <<"\n";
}
};
int main () {
Salary salaryEmployee;
salaryEmployee.input_salary();
salaryEmployee.display();
system("pause");
return 0;
}
Comments
Leave a comment