Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the definition of the following class: (1, 2, 3, 5 7) class employee {p

ID: 3812285 • Letter: C

Question

Consider the definition of the following class: (1, 2, 3, 5 7) class employee {public: employee (); employee (string, int, double); employee (int, double); employee (string); void setData (string, int, double); void print()const; void updateSalary (double x); int getNumOfServiceYears () cost; private: string name; int numOfServiceYears; double salary;}; a. Give the line number containing the constructor that is executed in each of the following declarations: i. employee tempEmployee; ii. employee newEmployee ("Harry Miller", 0, 25000); iii. employee oldEmployee ("Bill Dunbar", 15, 55000); b. Write the definition of the constructor in Line 4 so that the instance variables are initialized to "", 0, and 0.0, respectively. Write the definition of the constructor in Line 5 so that the instance variables are initialized according to the parameters. Write the definition of the constructor in Line 6 so that the instance variable name is initialized to the empty string and the remaining instance variables are initialized to the parameters.

Explanation / Answer

a.

i) employee tempEmployee;

Constructor is Line4 will get executed because of this statement.

ii) Employee newemployee("Harry Miller",0,25000);

Constructor in Line5 will get executed because of this statement because the arguments in this matches the datatypes given in the constructor at line4 only.

iii) Employee oldemployee("Bill Dunar",15,55000);

For this also Constructor in Line5 will get executed because of this statement because the arguments in this matches the datatypes given in the constructor at line4 only.