阅读背景:

为什么要通过参考而不是价值来传递?

来源:互联网 

From what I understand: when you pass by value, the function makes a local copy of the passed argument and uses that; when the function ends, it goes out of scope. When you pass by const reference, the function uses a reference to the passed argument that can't be modified. I don't understand, however, why one would choose one over the other, except in a situation where an argument needs to be modified and returned. If you had a void function where nothing is getting returned, why choose one over the other?From what I understand: when you pass by value,




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: