Is it some kind of enforced rule that the overload ++ function must take an int as argument to distinguish itself from prefix operators?
Also, In case of prefix overload ++ function, how does the right hand operand is implicit argument?
E.g ++ClassObj //ClassObj is rhs, but usualy lhs is made implicit
On the second issue. Both prefix and postfix
++are unary operators, they do not have a left-hand-side and right-hand-side operand, but a single operand on which they are applied. That is, inx++and++x,xis the operand, not the right hand/left hand, but the operand.Then on why the
intthat is required in the signature of the postfix version, it takes an artificial integer argument (which is not used) just to differentiate the signatures and allow the compiler to know that you are declaring/defining a postfix++and not the prefix version of it. Consider it as a tag, more than anything else, since the language requires different signatures.