|
|
|
|
|
|
|
The Payroll program in Chapter 1 uses the programmer-defined identifiers listed below. (Most of the other identifiers in the program are C++ reserved words.) Notice that we chose the names to convey how the identifiers are used. |
|
|
|
|
| Identifier | How It Is Used | | MAX_HOURS | Maximum normal work hours | | OVERTIME | Overtime pay rate factor | | payRate | An employee's hourly pay rate | | hours | The number of hours an employee worked | | wages | An employee's weekly wages | | total | The sum of weekly wages for all employees (total company payroll) | | empNum | An employee's identification number | | payFile | The output file (where the employee's number, pay rate, hours, and wages are written) | | CalcPay | A function for computing an employee's wages |
|
| |
|
|
|
|
Using Meaningful, Readable Identifiers |
|
|
|
| |
|
|
|
|
The names we use to refer to things in our programs are totally meaningless to the computer. The computer behaves in the same way whether we call the value 3.14159265, pi, or cake, as long as we always call it the same thing. However, it is much easier for somebody to figure out how a program works if the names we choose for elements actually tell something about them. Whenever you have to make up a name for something in a program, try to pick one that will be meaningful to a person reading the program. |
|
|
|
| |
|
|
|
|
C++ is a case-sensitive language. Uppercase letters are different from lowercase letters. The identifiers |
|
|
|
| |
|
|
|
|
PRINTTOPPORTION printtopportion pRiNtToPpOrTiOn PrintTopPortion |
|
|
|
| |
|
|
|
|
are four distinct names and are not interchangeable in any way. As you can see, the last of these forms is the easiest to read. In this book, we use combinations of uppercase letters, lowercase letters, and underscores in identifiers. We explain our conventions for choosing between uppercase and lowercase as we proceed through this chapter. |
|
|
|
|
|
|