Jump to content
  • Advertisement
Sign in to follow this  
y2jsave

postfix increment doubt !!

This topic is 2900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when we overload postfix operator ,
by using this ::

<class name> operator++ (int) ..
how does this int tells the compiler that we are overloading postfix and not prefix operator ??

Thanks in advance
y2jsave

Share this post


Link to post
Share on other sites
Advertisement
The unused "int" argument is the disambiguator. In no way intuitive or obvious, but that is C++.

Share this post


Link to post
Share on other sites
<class name> operator++ (int) is always the postfix ++, because of the (int) parameter. That parameter is ignored (because incrementing always increments by 1).

<class name> operator++ () is always the prefix ++, because it does not have the (int) parameter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!