http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.14
C++ FAQ suggests the following for post increment.
class Number { public: Number& operator++ (); // prefix ++ Number operator++ (int); // postfix ++ };
But actually is should be
const Number operator++(int);
to prevent num++++ which semantically doesn’t make any sense.
Similarily, operator+ should return const Number.
Leave a Reply