![]() |
![]() |
![]() |
![]() |
![]() |
|
Once you have introduced enumeration constants, you can improve the
clarity of the switch statement by replacing the integers
with those enumeration constants:
switch (type_code) {
case eng_code: train[n] = new engine; break;
case box_code: train[n] = new box_car; break;
case tnk_code: train[n] = new tank_car; break;
case cab_code: train[n] = new caboose; break;
}