Home Segments Index Top Previous Next

481: Mainline

In principle, you could replace integers with named integer constants. Then, you would need to maintain the correct correspondence between the sensor code for car types and the corresponding car type in just one place. Elsewhere, you have the mnemonic power of the integer-constant's name working for you.

For example, you could define integer constants as follows near the beginning of your program:

const int eng_code = 0; 
const int box_code = 1; 
const int tnk_code = 2; 
const int cab_code = 3;