A final point is that a literal value canβt be passed into a function by reference. The reference needs to point at a storage location, not a value. If there is a function void foo(string& s) the following would cause a compiler error:
When in doubt, pass by value. It is the safest option. If you are going to pass by reference, favor using a const reference. Passing off data to another function and letting that function modify the data tends to βhideβ what is happening and make it harder to reason about what a chunk of code does. A const reference avoids making extra copies but protects us from unwanted side effects that change data unexpectedly.