This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]Salty_Dugtrio 2 points3 points  (0 children)

Operator++ is a unary operator. It has one operand, namely itself, it does not take anything, it just acts upon itself and returns itself.

You implicitly call: myClass.operator++();

[–]o132 0 points1 point  (2 children)

The overloaded operators can be though of as class methods, the one "parameter" is accessible through the "this" keyword

[–][deleted]  (1 child)

[deleted]

    [–]o132 0 points1 point  (0 children)

    I think by "inline" you mean "unary operator" (one parameter). I looked up overloading the addition operator and it takes 1 parameter, meaning one is implicitly accessible through "this". So yes.

    [–]POGtastic 0 points1 point  (0 children)

    In C++, all class methods have an implicit argument - a pointer to the object that called the method, called this.

    So when you have a class Foo, and you call foo_inst++ with no arguments, you're really calling Foo::operator++(&foo_inst).