Datasheet
Employee.h
The Employee.h file declares the behavior of the Employee class. The sections of this file are described
individually in the material that follows.
// Employee.h
#include <iostream>
namespace Records {
The first few lines of the file include a comment indicating the name of the file and the inclusion of the
stream functionality.
This code also declares that the subsequent code, contained within the curly braces, will live in the
Records namespace. Records is the namespace that is used throughout this program for application-
specific code.
const int kDefaultStartingSalary = 30000;
This constant, representing the default starting salary for new employees, lives in the Records names-
pace. Other code that lives in Records can access this constant simply as
kDefaultStartingSalary.
Elsewhere, it must be referenced as
Records::kDefaultStartingSalary.
class Employee
{
public:
Employee();
void promote(int inRaiseAmount = 1000);
void demote(int inDemeritAmount = 1000);
void hire(); // Hires or rehires the employee
void fire(); // Dismisses the employee
void display(); // Outputs employee info to the console
// Accessors and setters
void setFirstName(std::string inFirstName);
std::string getFirstName();
void setLastName(std::string inLastName);
std::string getLastName();
void setEmployeeNumber(int inEmployeeNumber);
int getEmployeeNumber();
void setSalary(int inNewSalary);
int getSalary();
bool getIsHired();
The Employee class is declared, along with its public methods. The promote() and demote() methods
both have integer parameters that are specified with a default value. In this way, other code can omit the
integer parameters and the default will automatically be used.
30
Chapter 1
04_574841 ch01.qxd 12/15/04 3:39 PM Page 30










