Now suppose that your data contains an unknown car-type number. If you
like, you can handle such unknown car-type numbers using the default
part of the switch
statement. In the following example, you choose
to have unknown railroad-cartype numbers displayed on your screen:
switch (type_code) { case 0: train[n] = new engine; break; case 1: train[n] = new box_car; break; case 2: train[n] = new tank_car; break; case 3: train[n] = new caboose; break; default: cout << "Car-type number " << type_code << " is unknown!" << endl; }