Dereferencing Operator and Exception Handling...

From: Barry Hynes (hynesb_at_mar.dfo-mpo.gc.ca)
Date: 09/29/04


Date: Wed, 29 Sep 2004 14:30:14 GMT

Good Day Folks,

struct Link_ { // struct, because Link is private
      T value_;
      Link_* next_;
      Link_(const T&, Link_*); // link with the next element
    };

class List{
  ...

   class ListIterator{
      public:
         T& operator*() throw(domain_error);
         const T& operator*() const throw(domain_error);
         .....
       private:
          Link_* current_;
          List& myList_;
   };
.....
};

T& List::ListIterator::operator*(){
          return current_->value_;
    }
const T& List::ListIterator::operator*() const {
      return current_->value_;
    }

my question is how can you use exception handling on the two overloaded
dereferencing function?

i do not see anything i can test for...

if (current_->value_ == -1)
but value_ could actually be -1

not sure...maybe i am in the wrong ballpark ;)

anyhelp greatly appreciated

Barry