- pass objects as const reference when their size is 'relatively' big
Can anyone explain this?
- pass objects as const reference when their size is 'relatively' big
Can anyone explain this?
Can anyone explain this?- pass objects as const reference when their size is 'relatively' big
It was a 'why', not a 'how'.
It was a 'why', not a 'how'.
Pass by const-reference has the same semantics as pass-by-const-value, but the object isn't actually copied/cloned. As a rule of thumb, large objects are likely expensive to copy, so if you don't need to make copies, you should avoid it.