Tuesday, November 30, 2010

Postfix Increment

const MyClass operator++(int); is a postfix increment operator prototype.

MyClass& operator++(void); is a prefix increment operator prototype.

This can be remembered by the fact that the postfix increment needs to return a temporary value, and not an lvalue to the original object. So, the function return const is the postfix.

Note: postfix, infix, and prefix refer to the location of operator with respect to the operand.

No comments:

Post a Comment