List Iterator


Thanks a lot.
Last edited on
The * and postfix inc/dec operators should be
1
2
3
4
  Type& operator * () const;

  ListIterator operator ++ ( int );
  ListIterator operator -- ( int );


You'll also need the following
1
2
3
4
  Type* operator -> () const { return &(operator * ()); }
  
  ListIterator rbegin();
  ListIterator rend();


And you will probably also want
1
2
3
4
5
  ListIterator  operator +  ( ptr_diff_t n ) const;
  ListIterator& operator += ( ptr_diff_t n );

  ListIterator  operator -  ( ptr_diff_t n ) const;
  ListIterator& operator -= ( ptr_diff_t n );

and maybe
1
2
3
4
template <typename Type> inline
bool operator < ( const ListIterator& lhs, const ListIterator& rhs );

// and so on for <=  >  >= 


Since this is a custom iterator not derived from std::iterator it will not be compatible with any of the stl iterators. I don't know if this matters to you. (If it does, you'll have to take a look through the STL <iterator.h> and #included files to see how the STL does it.)

You will also need to be careful about the end() and rend() iterators.

Hope this helps.

BTW, please use [code] tags.

[edit] I don't know why people double-post in different forums. Would you please delete your duplicate thread from the General C++ forum? Thanks.
Last edited on
Topic archived. No new replies allowed.