Here, then, are the revised, fully protected, class definitions:
class link { friend class header; private: link *next_link_pointer; railroad_car *element_pointer; link (railroad_car *e, link *l) { element_pointer = e; next_link_pointer = l; } }; class header { public: header ( ) { first_link_pointer = NULL; current_link_pointer = first_link_pointer; } void add (railroad_car *new_element) { first_link_pointer = new link (new_element, first_link_pointer); current_link_pointer = first_link_pointer; } void advance ( ) { current_link_pointer = current_link_pointer -> next_link_pointer; } railroad_car* access ( ) { return current_link_pointer -> element_pointer; } int endp ( ) { return ! current_link_pointer; } void reset ( ) { current_link_pointer = first_link_pointer; } private: link *first_link_pointer; link *current_link_pointer; };