FAQ 23.07 How are the prefix and postfix versions of operator++ distinguished?They are distinguished by a dummy parameter. The postfix version, i++, is called operator++ and has a dummy parameter of type int. The prefix version, ++i, is also called operator++, but it has no dummy parameters. Here's an example. #include <iostream> using namespace std; class Fred { public: void operator++ () throw(); void operator++ (int) throw(); }; void Fred::operator++ () throw() { cout << "prefix: ++i\n"; } void Fred::operator++ (int) throw() { cout << "postfix: i++\n"; } int main() { Fred i; ++i; i++; } The output is prefix: ++i postfix: i++ The two versions of operator-- are similar: the prefix version takes no parameters and the postfix version takes a single parameter of type int. |