previous | start | next

## Implementing Linked Lists (The Classes for Lists, Nodes, and Iterators)

- An iterator denotes a position in the list.

  >     class Iterator
  >     {
  >     public:
  >        Iterator();
  >        string get() const;     /* use instead of * */
  >        void next();            /* use instead of ++ */
  >        void previous();        /* use instead of -- */
  >        bool equals(Iterator b) const; /* use instead of == */
  >     private:
  >        Node* position;
  >        Node* last;
  >     friend class List;
  >     };

- We will enable the operators `++`, `--`, `*` and `==` in the next chapter.
- If the iterator points past the end of the list, then the `position` pointer is `NULL`.
- The iterator stores a pointer to the last element of the list, so that the previous method can move the iterator back from the past-the-end position to the last element of the list.

previous | start | next