C++ Return value, reference, const reference

前端 未结 5 1509
花落未央
花落未央 2020-12-12 14:06

Can you explain to me the difference between returning value, reference to value, and const reference to value?

Value:

Vector2D oper         


        
5条回答
  •  不思量自难忘°
    2020-12-12 14:51

    As pointed out but luk32 it is just to ensure that no changes are allowed to the objects returned by this function. This can basically help you in finding your logical errors at compile time. Suppose you are sure not to change a object, and your code is changing the object, it can be tracked. It can be thought of a good coding practice.

提交回复
热议问题