Question
Consider the definition of the following class: (1,2,3,5,7) class emplyee { public: emplyee (); emplyee (string,int,double); emplyee(int,double); employee (string); void setData (string,int, double); void print
Consider the definition of the following class: (1,2,3,5,7)
class emplyee
{
public:
emplyee ();
emplyee (string,int,double);
emplyee(int,double);
employee (string);
void setData (string,int, double);
void print () const;
void updateSalary (double x);
int getNumOfServiceYears() const;
double getSalary () const;
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 temp Employee;
ii. employee new Employee (" Harry Miller", 0,2500);
iii. employee old Employee ("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.
c). Write the definition of the constructor in Line 5 so that the instance variables are initialized according to the parameters.
d). Write the definition of the constructor in line 6 so that the insurance variable name is initialized to empty string and the remaining instance variables are initialized according to the parameters.
Step by Step Solution
3.46 Rating (143 Votes )
There are 3 Steps involved in it
Step: 1
class emplyee public employee name numOfServiceYears ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started