As we saw on page 553, we can explicitly call an overloaded operator as an alternative to using it as an operator in an expression. If we want to call the postfix version using a function call, then we must pass a value for the integer argument:
StrBlobPtr p(a1); // p points to the vector inside a1
p.operator++(0); // call postfix operator++
p.operator++(); // call prefix operator++
The value passed usually is ignored but is necessary in order to tell the compiler to use the postfix version.
Exercise 14.27: Add increment and decrement operators to your StrBlobPtr
class.
Exercise 14.28: Define addition and subtraction for StrBlobPtr
so that these operators implement pointer arithmetic (§ 3.5.3, p. 119).
Exercise 14.29: We did not define a const
version of the increment and decrement operators. Why not?