Say you have:
int f( const T a ) { ... }
int g( const T &a ) { ... }
I understand the use of const
in g
: we don't know how a
is used outside the function, so we want to protect it from being modified. However I don't understand the use of const
in f
, where a
is a local copy. Why do we need to protect it from being modified?