Listing 2
class STLGlobIterator : public std::iterator< std::forward_iterator_tag , const std::string , int > { public: STLGlobIterator() : list_( NULL ) , current_() { return ; } STLGlobIterator( char** list ) : list_( list ) , current_( *( list_ ) ) { ++list_ ; return ; } STLGlobIterator( const STLGlobIterator& other ) : list_( other.list_ ) , current_( other.current_ ) { return ; } self_reference operator=( const STLGlobIterator& other ){ if( this == &other ){ return( *this ) ; } list_ = other.list_ ; current_ = other.current_ ; return( *this ) ; } self_reference operator++(){ if( NULL != *list_ ){ current_ = *list_ ; ++list_ ; } else{ current_ = "[past the end!!]" ; list_ = NULL ; } return( *this ) ; } self_type operator++(int){ self_type result( *this ) ; ++( *this ) ; return( result ) ; } bool operator==( const self_reference other ){ return( other.list_ == this->list_ ) ; } bool operator!=( const self_reference other ){ return( ! ( (*this) == other ) ) ; } reference operator*(){ return( current_ ) ; } reference operator->(){ return( *( *this ) ) ; } private: char** list_ ; std::string current_ ; } ;