Datasheet

bool AirlineTicket::getHasEliteSuperRewardsStatus()
{
return (fHasEliteSuperRewardsStatus);
}
void AirlineTicket::setHasEliteSuperRewardsStatus(bool inStatus)
{
fHasEliteSuperRewardsStatus = inStatus;
}
The preceding example exposes you to the general syntax for creating and using classes. Of course, there
is much more to learn. Chapters 8 and 9 go into more depth about the specific C++ mechanisms for
defining classes.
Your First Useful C++ Program
The following program builds on the employee database example used earlier when discussing structs.
This time, you will end up with a fully functional C++ program that uses many of the features discussed
in this chapter. This real-world example includes the use of classes, exceptions, streams, arrays, names-
paces, references, and other language features.
An Employee Records System
A program to manage a company’s employee records needs to be flexible and have useful features. The
feature set for this program includes the following.
The ability to add an employee
The ability to fire an employee
The ability to promote an employee
The ability to view all employees, past and present
The ability to view all current employees
The ability to view all former employees
The design for this program divides the code into three parts. The
Employee class encapsulates the
information describing a single employee. The
Database class manages all the employees of the com-
pany. A separate
UserInterface file provides the interactivity of the program.
The Employee Class
The Employee class maintains all the information about an employee. Its methods provide a way to
query and change that information.
Employees also know how to display themselves on the console.
Methods also exist to adjust the employee’s salary and employment status.
29
A Crash Course in C++
04_574841 ch01.qxd 12/15/04 3:39 PM Page 29