I have code very similiar to this:
LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const
{
return (this + &am
Other answers explained already why, what You are doing doesn't work, but my guess is, that You want to define typical operator+
for an iterator, but got lost in that attempt.
Both pointers and standard random access iterators allow to advance the pointer or iterator by an integral value. In case of iterators, an operator+
is defined, that takes an integral value as an argument and returns an iterator.
LINT_rep::Iterator LINT_rep::Iterator::operator+(int distance) const;
You can define such operator as a method, but this method will allow You to write
iterator + distance
but not
distance + iterator
To make the addition commutative You have to define a friend non-member function that takes the distance as the first parameter and an iterator object as a second
friend LINT_rep::Iterator LINT_rep::Iterator::operator+(int distance, const LINT_rep::Iterator & rhs);