2) Consider the code below: Employee class: class Employee { public: Employee(st
ID: 3703801 • Letter: 2
Question
2) Consider the code below: Employee class: class Employee { public: Employee(string theName, float thePayRate); protected: string getName0 const; float getPayRate0 const; float pay(float hours Worked) const; private: string name float payRate; Definitions for some of the methods follow: Employee::Employee(string theName, float thePayRate) name theName; payRate -thePayRate; float Employee::pay(float hours Worked) const return hours Worked * payRate; Manager Class #include "employee"h" class Manager : public Employee public: Manager(string theName, float thePayRate, bool isSalaried); protected: bool getSalaried0 const; float pay(float hours Worked) const; private: bool salaried;Explanation / Answer
A.) Class Manager is a derived class of base class Employee .
B.)
enum var { Val1, val2}; //declaration of enum.
// By default enum first member value is 0.
If we will assigne Val1 to salaried it become zero,and if we will assign val2 to salaried then it becomes 1(true),in respect of enum.
Salaried = Val1; // salaried become 0 i.e (false).
salaried = Val2; //salaried become 1 i.e (true).
C.)
The output of the following code is error.
In both cout it is calling the protected member of class which is invalid.
Cout<<"Pay:"<<emp1P->pay(40.0);//error.
Thankyou.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.