Answer to Question #276011 in C++ for Asim

Question #276011

Derive a class called employee2 from the employee class in the EMPLOY program in this


chapter. This new class should add a type double data item called compensation, and


also an enum type called period to indicate whether the employee is paid hourly, weekly,


or monthly. For simplicity you can change the manager, scientist, and laborer classes


so they are derived from employee2 instead of employee. However, note that in many


circumstances it might be more in the spirit of OOP to create a separate base class called


compensation and three new classes manager2, scientist2, and laborer2, and use


multiple inheritance to derive these three classes from the original manager, scientist,


and laborer classes and from compensation. This way none of the original classes


needs to be modified.

1
Expert's answer
2021-12-06T05:27:09-0500
#include <iostream>
#include <string>

class employee
{
    std::string employee_name;
};
class employee2 : public employee
{
    std::string role;
};
class compensation
{
    double compensation;
    enum Period {hourly, weekly, monthly};
};
class manager : public employee2, public compensation
{
    
};
class laborer : public employee2, public compensation
{
    
};
class scientist : public employee2, public compensation
{
    
};

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