You could use a member variable to hold the grid point it is currently pointing to:
class spGridIterator {
public:
typedef forward_iterator_tag iterator_category;
typedef spVector3D value_type;
typedef int difference_type;
typedef spVector3D* pointer;
typedef spVector3D& reference;
spGridIterator(spGrid* gr, int index);
spGridIterator& operator++();
spGridIterator& operator++(int);
reference operator*() const;
pointer operator->() const;
private:
spGrid* m_grid;
int m_idx;
spVector3D CurrentPoint;
};
Then the dereference operator could look like this:
spGridIterator::reference spGridIterator::operator*() const {
CurrentPoint = m_grid->GetPoint(m_idx);
return CurrentPoint;
}
Space_C0wb0y
2010-10-29 09:07:41