Consider the definition of the class employee as given below. Answer the followi
ID: 3571964 • Letter: C
Question
Consider the definition of the class employee as given below. Answer the following questions:
class employee //Line 1
{ //Line 2
public: //Line 3
employee(); //Line 4
employee(string, int, double); //Line 5
employee(int, double); //Line 6
employee(string); //Line 7
void setData(string, int, double); //Line 8
void print() const; //Line 9
void updateSalary(double x); //Line 10
int getNumOfServiceYears() const; //Line 11
double getSalary() const; //Line 12
private: //Line 13
string name; //Line 14
int numOfServiceYears; //Line 15
double salary; //Line 16
}; //Line 17
a.) Write the definition of the function setData so that the instance variables are set according to the parameters.
b.) Write the definition of the function print to output the values of the instance variables.
c.) Write the definition of the function updateSalary to update the value of the instance variable salary by adding the value of the parameter.
d.) Write the definition of the function getNumOfServiceYears to return the value of the instance variable numOfServiceYears.
Explanation / Answer
1. The definition of the function setData :-
public void setData(string, int, double)
{
this.name = name ;
this.numOfServiceYears = numOfServiceYears ;
this.salary = salary ;
}