Questions: Based on the following declaration of the Employee class, and that Manager inherits from the Employee class, which of the following are true? ``` class Employee public: Employee(); Employee(string newname); Employee(double newsalary); Employee(string newname, double newsalary); void setname(string newname); string getname()const; private: string name; double salary; ; ``` The Manager class does not inherit the private data members. A Manager object has direct access to the name and salary inherited data members. The Manager class inherits name and salary, but Manager functions cannot change the values of either data member. The Manager class inherits name and salary, but Manager functions can only change the values of the name data member.

Based on the following declaration of the Employee class, and that Manager inherits from the Employee class, which of the following are true?

```
class Employee

public:
    Employee();
    Employee(string newname);
    Employee(double newsalary);
    Employee(string newname, double newsalary);
    void setname(string newname);
    string getname()const;
private:
    string name;
    double salary;
;
```

The Manager class does not inherit the private data members.
A Manager object has direct access to the name and salary inherited data members.
The Manager class inherits name and salary, but Manager functions cannot change the values of either data member.
The Manager class inherits name and salary, but Manager functions can only change the values of the name data member.
Transcript text: Based on the following declaration of the Employee class, and that Manager inherits from the Employee class, which of the following are true? ``` class Employee { public: Employee(); Employee(string new_name); Employee(double new_salary); Employee(string new_name, double new_salary); void set_name(string new_name); string get_name()const; private: string name; double salary; }; ``` The Manager class does not inherit the private data members. A Manager object has direct access to the name and salary inherited data members. The Manager class inherits name and salary, but Manager functions cannot change the values of either data member. The Manager class inherits name and salary, but Manager functions can only change the values of the name data member.
failed

Solution

failed
failed

Solution Steps

Step 1: Understand the Class Structure

The Employee class has private data members name and salary. It also has public member functions and constructors.

Step 2: Inheritance and Access

When a class inherits from another class, it inherits all data members and member functions. However, private data members of the base class are not directly accessible by the derived class.

Step 3: Evaluate the Statements
  1. The Manager class does not inherit the private data members.

    • Incorrect. The Manager class does inherit the private data members, but they are not directly accessible.
  2. A Manager object has direct access to the name and salary inherited data members.

    • Incorrect. Private data members are not directly accessible by the derived class.
  3. The Manager class inherits name and salary, but Manager functions cannot change the values of either data member.

    • Incorrect. Manager functions can change the values using public member functions of the base class.
  4. The Manager class inherits name and salary, but Manager functions can only change the values of the name data member.

    • Incorrect. Manager functions can change both name and salary using public member functions of the base class.

Final Answer

None of the provided statements are correct.

Was this solution helpful?
failed
Unhelpful
failed
Helpful