Example 5-24. Overloading the increment operator
enum status { stopped, running, waiting };
status& operator++(status& s) { // Prefix
if (s != waiting)
s = status(s + 1);
return s;
}
status operator++(status& s, int) { // Postfix
status rtn = s;
++s;
return rtn;
}
int main( )
{
status s(stopped);
++s; // Calls operator++(s);
s++; // Calls operator++(s, 0);
}