C++ pass by reference for large objects

c++

Solution

In general, yes. You should always pass large objects by reference (or pass a pointer to them, especially if you are using C).

Problem

If I have a C++ function declaration: ``` int func(const vector<int> a) ``` Would it always be beneficial to replace it with ``` int func(const vector<int> &a) ``` since the latter does not need to make a copy of `a` to pass into the function?

Original source