Question: Consider a class Employee with data members: age (an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class

Consider a class Employee with data members: age(an integer), id (an integer) and salary (a float), and their corresponding member functions as follows:

class Employee

{

private:

int age;

int id;

float salary;

public:

Employee(); // default constructor: age = 0, id = 0, salary = 0.0

Employee(int x, int y, float z); // parameterized constructor: age=x, id=y,

// salary=z

~Employee(); // destructor: age = 0, id = 0, salary = 0.0

Employee(const Employee &x); // copy constructor

Employee & operator =(const Employee &x); // = operator overloading

void setAge(int x);

void setId(int x);

void setSalary(float x);

int getAge( );

int getId( );

float getSalary( );

};

You need to provide the definition of all the above member functions. Write a main routine in which you create an array of Employee with 3 elements. Set the first element with the content (age=30, id = 30042554, salary=50000.00), the second element with the content (age=45, id=40041002, salary=60000.00), and the third element with the content (age=50, id=40041004, salary=70000.00). by using the setXXX member functions. Then, pass the array to a function, PrintEmployee(arg1, arg2), in which arg1 should be the array of Employee and arg2 is the length of the array (=3 in this case). In PrinteEmployee(arg1, arg2), write a for loop to print out the information of each employee by using the fourth through sixth member functions and cout (in this case, we have three employees in total).

The skeletons of the main( ) and PrintEmployee() are as follows:

void main( )

{

// create an array of Employee with three elements

Employee x[3];

..

// set the values for the three elements of the array by using public member functions

// call PrintEmployee( ) with a proper parameter list

PrintEmplyee( arg1, arg2);

Employee w( ); // position 1

// print out the information of w

.

Employee v(30, 40041006, 35000.0); // position 2

// print out the information of v

.

Employee u(v); // position 3

// print out the information of u

.

Employee y=v; // position 4

// print out the information of y

.

w=y; // position 5

// print out the information of w

.

}

void PrintEmployee(arg1, arg2)

{

// for loop

// Print out the information of each element by using public member functions

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!