![]() |
![]() |
![]() |
![]() |
![]() |
|
Of course, when the value of
type_code was an integer, it was straightforward to build
a switch statement around the value of type_code to pick
out the right sort of class object to create:
switch (type_code) {
case eng_code: train[n] = new engine; break;
...
}
To deal with a string stored in input_buffer, your program has to do
more work, because it has to extract a type-indicating character from the
array holding the serial number. Then, it must decide what to do by noting
which character it has extracted.