Why using const for arguments passed by value?
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 do we need to protect it from being modified?
No comments:
Post a Comment