0

Possible Duplicate:
Operator overloading

Suppose I have a class Foo and I want to to overload the postfix increment operator. I do something like:

class Foo{
.....
public:
   friend Foo& operator++(Foo&, int);

and then I define the new operator somewhere. What I really cannot figure out is where does this int come from.

If I have: f = Foo(); I can do:

f++;

and this seems to me to be unary.

How is the syntactic rule?

In the tests I ran the int value passed was 0. Is ti always zero?

Community
  • 1
  • 1
Aslan986
  • 9,984
  • 11
  • 44
  • 75

1 Answers1

1

int parameter is just a convention, hint for the compiler to differentiate between prefix and postfix operators.

Marius
  • 833
  • 5
  • 11
  • more than just a hint, and [MSDN](http://msdn.microsoft.com/en-us/library/f6s9k9ta(v=vs.100).aspx) indicates using anything other than int is an error. – crashmstr May 04 '12 at 13:04