I tutor students in C++, and recently came across a problem involving pointer arithmetic with array names. The main thing I\'m confused about is the statement
You should not confuse the return value of an operator and the priority.
The first is dealing with what the operator returns, the second deals with when something happens.
So if you have:
T min_value = *begin++;
Here is how it works:
operator++ - it increments the pointer, but returns the pointer that was there originally.operator* - dereferences the pointer returned previously, returns T that it pointed to.operator= stores left-hand side into right-hand side, returns right-hand side.You don't use the last return value, but you theoretically could.
Note here, that in #2 you use the return from #1, rather than accessing the pointer again.