Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Derive a class Manager from Employee. Add a data field, named department, of type string. Supply a function print that prints the managers name, department,

Derive a class Manager from Employee. Add a data field, named department, of type string. Supply a function print that prints the managers name, department, and salary. Derive a class Executive from Manager. Supply a function print that prints the string Executive, followed by the information stored in the Manager base object

include ccc_empl.h

#ifndef CCC_EMPL_H

#define CCC_EMPL_H

#include

using namespace std;

class Employee

{

public:

Employee();

Employee(string employee_name, double initial_salary);

void set_salary(double new_salary);

double get_salary() const;

string get_name() const;

private:

string name;

double salary;

};

#endif

and ccc_empl.cpp

#include \"ccc_empl.h\"

Employee::Employee()

{

salary = 0;

}

Employee::Employee(string employee_name, double initial_salary)

{

name = employee_name;

salary = initial_salary;

}

void Employee::set_salary(double new_salary)

{

salary = new_salary;

}

double Employee::get_salary() const

{

return salary;

}

string Employee::get_name() const

{

return name;

}

You will develop the following header and sources files for manager and executive classes

manager.h

#ifndef MANAGER_H #define MANAGER_H

#include #include #include \"ccc_empl.h\"

using namespace std;

class manager : public Employee { public:

manager(); manager (string name, double salary, string dept); string get_department() const; void print() const; private: string department; }; #endif

manager.cpp

#include #include

#include \"manager.h\"

using namespace std;

manager::manager() { } manager::manager (string name, double salary, string dept) : Employee(name , salary) { department = dept; } string manager:: get_department() const { return department; } void manager::print()const { cout\"works> }

executive.h

#ifndef EXECUTIVE_H #define EXECUTIVE_H

#include #include #include \"manager.h\"

using namespace std;

class executive : public manager { public:

executive(); executive (string name, double salary, string dept, double bn); string get_department() const; void print() const; private: double bonus; }; #endif

execuitve.cpp

#include #include

#include \"executive.h\"

using namespace std;

executive::executive() { } executive::executive (string name, double salary, string dept) : manager(name , salary , dept) { } void executive::print()const { cout manager::print(); }

staffTest.cpptest program / driver

#include #include

#include \"ccc_empl.h\" #include \"manager.h\" #include \"executive.h\"

using namespace std;

int main()

{ executive m = executive(\"bigwig, bill\",1360000, \"sales\"); return 0; }

1. Create a manager:

name: King, Lary

salary: 65000

department: Finance

2. Create an executive:

name: BigWig, Bill

salary: 100000

bonus: 5000

department: Sales

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

13. Let X be exponential with mean 1/; that is, fX (x) = ex , 0 1].

Answered: 1 week ago