Question: Finish the code based on the skeleton code provided. Task1: employee.cpp is given and employee.h is partially completed. Read main.cpp to see how dynamic binding

Finish the code based on the skeleton code provided.

Task1:

employee.cpp is given and employee.h is partially completed. Read main.cpp to see how dynamic binding is used and declare some of the functions of Employee class as virtual. Since employee is an abstract base class, there is one pure virtual function. Which function should you declare as pure virtual?

Task2"

Complete the rest of constructor and destructor of Employee, and the implementation of classes Cook, DeliveryMen and Manager.(For other headers, need to make our own just as employee.h) When implementing the print_description() method of the subclasses, you may need to call the method of Employee class. You have to allocate dynamic memory for the name of Employee. strlen() and strcpy() functions are useful here.

>employee.cpp

Finish the code based on the skeleton code provided. Task1: employee.cpp is

>employee.h

given and employee.h is partially completed. Read main.cpp to see how dynamic

>main.cpp

binding is used and declare some of the functions of Employee class

Sample Output

as virtual. Since employee is an abstract base class, there is one

#include #include #include "employee.h" using namespace std; Employee:: Employee(const char* name) { // 1. Allocate dynamic memory for private member "name" // Hint: strlen() function is useful here // 2. Copy the name using strcpy } Employee:: Employee() { cout #include "cook.h" #include "DeliveryMen.h" #include "manager.h" using namespace std; int main(int argc, char **argv) { Manager manager{"Bob", 20000}; manager.hire(new Cook ("Alice", 100, 80), 1); manager.hire(new DeliveryMen("Chris", 90, 150), 2); manager.hire(new Cook("Bob", 90, 100),1); manager.hire(new DeliveryMen ("Amy", 100, 50), 2); manager.pay_salary(); return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Employee: Alice Duty: Cook Salary: 8000 Employee: Chris Duty: DeliveryMen Salary: 13500 Employee: Bob Duty: Cook Salary: 9000 Employee: Amy Duty: DeliveryMen Salary: 5000 Employee: Bob Duty: Manager Salary: 20300 Cook Dtor Employee Dtor: Alice DeliveryMen Dtor Employee Dtor: Chris Cook Dtor Employee Dtor: Bob DeliveryMen Dtor Employee Dtor: Amy Manager Dtor Employee Dtor: Bob

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!