Finally, to reset the current_link_pointer
so that it points to the
first link
, you define reset
:
class header { public: link *first_link_pointer; link *current_link_pointer; 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; } };