Datasheet
try {
Employee& emp = inDB.getEmployee(employeeNumber);
emp.promote(raiseAmount);
} catch (std::exception ex) {
cerr << “Unable to promote employee!” << endl;
}
}
doFire() and doPromote() both ask the database for an employee by their employee number and then
use the public methods of the
Employee object to make changes.
Evaluating the Program
The preceding program covers a number of topics from the very simple to the more obscure. There are a
number of ways that you could extend this program. For example, the user interface does not expose all
of the functionality of the
Database or Employee classes. You could modify the UI to include those fea-
tures. You could also change the
Database class to remove fired employees from the mEmployees array,
potentially saving space.
If there are parts of this program that don’t make sense, consult the preceding sections to review those
topics. If something is still unclear, the best way to learn is to play with the code and try things out.
For example, if you’re not sure how to use the ternary operator, write a short
main() function that tries
it out.
Summary
Now that you know the fundamentals of C++, you are ready to become a professional C++ programmer.
The next five chapters will introduce you to several important design concepts. By covering design at a
high-level without getting into too much actual code, you will gain an appreciation for good program
design without getting bogged down in the syntax.
When you start getting deeper into the C++ language later in the book, refer back to this chapter to brush
up on parts of the language that you may need to review. Going back to some of the sample code in this
chapter may be all you need to see to bring a forgotten concept back to the forefront of your mind.
41
A Crash Course in C++
04_574841 ch01.qxd 12/15/04 3:39 PM Page 41










