Consider the definition of the following class: (1,2,3,5,7) class emplyee { public: emplyee (); emplyee (string,int,double); emplyee(int,double);
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 () 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.
Operating Systems Internals and Design Principles
ISBN: 978-0133805918
8th edition
Authors: William Stallings