operator ++()有什么区别?呼叫和++(* this)?

问题描述 投票:0回答:1

我正在类构造函数中调用operator ++(),建议使用operator ++();而不是++(* this)。两者有什么区别?

c++
1个回答
1
投票

基本上没有区别。 ++(*this)被重写为operator++()的调用。

在晦涩的情况下,过载的解决方案可能会有所不同,但是您可能想要避免仍然会发生这种情况。

我会使用++(*this)

© www.soinside.com 2019 - 2024. All rights reserved.