There is such a book as "The Design and Evolution of C++" by Bjarne Stroustrup (the only book of Stroustrup that I advice to read) where he described the history of introducing the syntax for prefix and postfix decrement and increment operators.
At first in C++ there is no difference of postfix and prefix operators. Usually they were defined as
1 2 3 4 5
|
class A
{
//
void operator ++();
};
|
So these statements were equivalent
To distinguish postfix and prefix operators it was suggested the following syntax
1 2 3 4 5
|
class A
{
A & operator prefix++();
A operator postfix++();
};
|
But it required to introduce two new keywords.
Another alternative was
1 2 3 4 5
|
class A
{
A & ++operator ();
A operator++();
};
|
At last it was decided to use an additional dummy parameter for the postfix operator. So when the compiler sees code something as
a++;
it would know that it has to substitute it to
A operator ++( int );
So when the compiler sees an expression like
++a;
it knows that it must substitute it for
A & operator ++();
and when it sees an expression like
a++;
it knows that it must use
A operator ++( int );