Next: bug reports Prev: placement new syntax Up: User Problems Top: Top

3.5. Overloaded increment (++) and decrement (--) operators

``g++ doesn't seem to distinguish the prefix and postfix forms of operator++. What gives?''

This is a relatively new feature in the C++ language. The solution is to upgrade your compiler; distinguishing the prefix and postfix cases of operator++ and operator-- was first implemented in g++ version 2.4.1.

For backward compatibility, if a class declares a prefix version of operator++ (or operator--) but no postfix version, and code attempts to use ++ (or --) as a postfix operator, g++ will use the prefix version (unless -pedantic is set). This feature is to avoid breaking old code.