return value of operator overloading in C++

前端 未结 5 2112
逝去的感伤
逝去的感伤 2020-11-29 18:19

I have a question about the return value of operator overloading in C++. Generally, I found two cases, one is return-by-value, and one is return-by-reference. So what\'s the

5条回答
  •  难免孤独
    2020-11-29 18:38

    Usually you return by reference in an operation that changes the value of the things it's operating on, like = or +=. All other operations are return by value.

    This is more a rule of thumb, though. You can design your operator either way.

提交回复
热议问题