[英]What is the difference between operator++(); call and ++(*this)?
I'm calling operator++() in my class constructor, and it is recommended to use operator++();我在我的类构造函数中调用了operator++(),建议使用operator++(); instead of ++(*this).而不是 ++(*this)。 What is the difference between the two?两者有什么区别?
There is essentially no difference.本质上没有区别。 ++(*this)
is rewritten to an invocation of operator++()
. ++(*this)
被重写为对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)
.我会使用++(*this)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.