August 2012
Intermediate to advanced
976 pages
30h 17m
English
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 a1p.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.
Exercises Section 14.6
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 ...
Read now
Unlock full access