Home Segments Index Top Previous Next

610: Mainline

Having redeclared the type-defining enumeration constants, you need only to replace the conditional part of the switch statement; the rest remains as it was:

switch (extract_car_code (input_buffer)) { 
  case eng_code: train[n] = new engine;   break; 
  ... 
} 

Thus, enumeration constants provide a form of detail-hiding data abstraction, and, as is usual with data abstraction, the use of enumeration constants simplifies change.