Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add the following overloaded operators to the Employee class (developed in Lab2): Overload the operator = - It should copy each of data members of

Add the following overloaded operators to the Employee class (developed in Lab2): Overload the operator = - It should copy each of data members of the Employee object Overload the operator + - It should add the Salary and Retirement contribution of two Employee objects and create another Employee object with Employee Name as Aggregate and ID as 111. Overload the operator <<: - Output the Name, Employee ID, Salary and Retirement Contributions in separate lines Test the overloaded operators by creating three different employee objects. The program should prompt the user to enter the data for creating these employee objects. The program should output the result of these operations (= and +) using the overloaded operator <<. `The program should be developed in Visual Studio

lab#2

#include

#include #include using namespace std;

// Class Declaration class Employee { //Access - Specifier private:

//Varibale Declaration string name; int Emp_ID; int Salary; double retirement_cont; public: Employee(); Employee(string emp_name,int emp_id,int sal,double ret_count); int getSal(void); double getRet(void); void DisplayEmp(void); };

Employee::Employee(string emp_name,int emp_id,int salary,double ret_cont=0 ) { name=emp_name; Emp_ID=emp_id; Salary=salary; retirement_cont=(0.06)*salary; }

int Employee::getSal(void){ return Salary; }

double Employee::getRet(void){ return retirement_cont ; }

void Employee::DisplayEmp(void){ cout<<"-------------Displaying Employee Information-------" << endl; cout << "Employee Name: " << name << endl; cout << "Employee ID: " << Emp_ID << endl; cout << "Employee Salary: " << getSal() << endl; cout << "Employee Retirement Contributions: " << getRet() << endl; cout << "monthly gross salary of the employee: " << getSal()/12 << endl; cout << "Net Salary of the employee: " << getSal()-getRet() << endl; cout<<"--------------------" << endl; }

//Main Function int main() { // Object Creation For Class Employee obj1=Employee("alex",111,12000); cout << "Employee Salary: " << obj1.getSal() << endl; cout << "Employee Retirement Contributions: " << obj1.getRet() << endl; obj1.DisplayEmp(); Employee obj2=Employee("brain",112,100000); cout << "Employee Salary: " << obj2.getSal() << endl; cout << "Employee Retirement Contributions: " << obj2.getRet() << endl; obj2.DisplayEmp(); Employee obj3=Employee("catia",111,12000); cout << "Employee Salary: " << obj3.getSal() << endl; cout << "Employee Retirement Contributions: " << obj3.getRet() << endl; obj3.DisplayEmp(); Employee obj4=Employee("brain",114,40000); cout << "Employee Salary: " << obj4.getSal() << endl; cout << "Employee Retirement Contributions: " << obj4.getRet() << endl; obj4.DisplayEmp(); Employee obj5=Employee("ela",115,15630 ); cout << "Employee Salary: " << obj5.getSal() << endl; cout << "Employee Retirement Contributions: " << obj5.getRet() << endl; obj5.DisplayEmp(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+what kinds of policies and practices should be developed?

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago