Home Segments Index Top Previous Next

770: Mainline

Next, you must substitute the appropriate parameter names wherever black bars have appeared in Segment 768, and you must provide a specializing argument wherever another template class name is used. For example, whenever you refer to the header class inside the definition of the link class, you must provide an argument surrounded by brackets, thus specializing the header template to the same class as that to which the link is specialized.

template  class link { 
  friend class header; 
    link *next_link_pointer; 
    link_parameter *element_pointer; 
    link (link_parameter *e, link *l) { 
      element_pointer = e; 
      next_link_pointer = l; 

Thus, the purpose of the template parameters is to set up slotlike locations into which the template mechanism eventually places instantiating symbols. In the railroad-car–list example, link_parameter is destined to be replaced by railroad_car when the template class is put to use.