![]() |
![]() |
![]() |
![]() |
![]() |
|
First, as you begin to think about how to define the iterator
constructor, note that the parameter declaration should indicate that the
argument is to be handed over as is, rather than copied, for there is no
point in copying the list header:
iterator (header& header) {...}
Then, given the header object, your constructor can
obtain a pointer to the first link object as follows:
header.first_link_pointer
Next, you can assign the value of header.first_link_pointer to the
iterator object's first_link_pointer member variable;
then, you can assign the same value to the iterator object's
current_link_pointer member variable:
first_link_pointer = header.first_link_pointer; current_link_pointer = first_link_pointer;