![]() |
![]() |
![]() |
![]() |
![]() |
|
Now, you can have your program create a railroad_car-specific list
using the generic header template class. In Chapter 47, the
analyze_train program used a statement that defined the train
variable to belong to the single-purpose header class:
header train;
Next, you can replace that statement with one that defines the train
variable to belong to a parameterized version of the generic
header class:
headertrain;
This expression causes the header template class to be
instantiated so as to deal with objects belonging to the
railroad_car class.
Next, the header template class activates the link
template class, because the header template class contains
embedded link<header_parameter> expressions. Thus, the
link class is also instantiated so as to deal with
railroad_car objects.
Note, that these instantiations do not prevent your program from building
other lists of railroad_car objects, nor does it prevent your
program from building lists of other kinds of objects. You can write
programs that construct as many lists as you like for as many object types
as you like.