Where should I prefer pass-by-reference or pass-by-value?
There are four main cases where you should use pass-by-reference over pass-by-value: If you are calling a function that needs to modify its arguments, use pass-by-reference or pass-by-pointer. Otherwise, you’ll get a copy of the argument. If you’re calling a function that needs to take a large object as a parameter, pass it by const … Read more