简体   繁体   中英

What is the difference between operator++(); call and ++(*this)?

I'm calling operator++() in my class constructor, and it is recommended to use operator++(); instead of ++(*this). What is the difference between the two?

There is essentially no difference. ++(*this) is rewritten to an invocation of operator++() .

It is possible that in obscure cases the overload resolution could be different, but you probably want to avoid the scenarios where that would be the case anyway.

I would use ++(*this) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM