Answer to Question #222497 in C++ for Jaguar

Question #222497
(c) Consider the partial class declaration of an Employee class below:
class Employee: protected Person{
public:

//...
double Rate;
double GetRate() const;
double GetHours() const;
private:
double Hours;
//...
protected:
double Pay() const;
//...
};

(i) The code fragment below (extracted from a main() function) has three invalid
statements. Write down the line numbers of the invalid statements and explain
why each of these statements is invalid. E is an instance of an Employee
object.

Line 1: cout << E.GetName();
Line 2: cout << E.GetHours();
Line 3: cout << E.Address;
Line 4: cout << E.GetRate();
Line 5: cout << E.Rate;
Line 6: cout << E.Pay();
1
Expert's answer
2021-08-04T04:08:01-0400
  1. Line 1: The employee class has no member called "GetName"
  2. Line 3: The employee class has no data member called "Address"
  3. Line 6: the Pay() function is protected in the class hence it cannot be accessed in main function.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS