C Derived Classes Inheritance File Employeeh Employee Class Definition Ifndef Employeeh De Q37125041

/************** C++ derived classes and inheritance**************/

Take the code weve provided for the Employee class (Employee.h and the Manager class (Managerh D). Add methods to the classe

/***********************************************************/

/** File: employee.h

* Employee class definition.

*/

#ifndef _EMPLOYEE_H

#define _EMPLOYEE_H

#include <string>

using namespace std;

class Employee {

public:

Employee(string theName, float thePayRate);

string getName() const;

float getPayRate() const;

float pay(float hoursWorked) const;

protected:

string name;

float payRate;

};

/** Employee method definitions.

*/

Employee::Employee(string theName, float thePayRate)

{

name = theName;

payRate = thePayRate;

}

string Employee::getName() const

{

return name;

}

float Employee::getPayRate() const

{

return payRate;

}

float Employee::pay(float hoursWorked) const

{

return hoursWorked * payRate;

}

#endif /* not defined _EMPLOYEE_H */

/***********************************************************/

//File: manager.h

//Manager class definition.

#ifndef _MANAGER_H

#define _MANAGER_H

#include “employee.h”

class Manager : public Employee {

public:

Manager(string theName,

float thePayRate,

bool isSalaried);

bool getSalaried() const;

float pay(float hoursWorked) const;

protected:

bool

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.