Home Segments Index Top Previous Next

732: Mainline

In the header definition, you need to declare a pointer to the first link object; in the link definition, you need to declare a member variable for a pointer to the next link object and a member variable for a pointer to a railroad_car object. The definition of the link class must come first, because a link pointer appears in the definition of the header class:

class link { 
  public:  link *next_link_pointer; 
           railroad_car *element_pointer; 
           ... 
}; 
class header { 
  public:  link *first_link_pointer; 
           ... 
};