Is there a way to implement operator->, not only operator*. To have following code working:
Iterator<value> it = ...
i = (*it).get();
i = it->get(); // also works
Let we say that value type has method get.
When Iterator is implemnted as below:
template<T> class Iterator {
T operator*() { return ... }
T operator->() { return ... }
}
Here … is an implementation of getting right T object.
Somehow it won’t work when I implement it in this way. I think I misunderstand something.
operator->should return a pointer:operator*should return a reference if you want to use it for modification: