R
Richard Cavell
Hi,
The point of using const on a parameter to a function should be to let
your compiler know that the parameter shouldn't be modified during your
program. This allows you to keep your code safe and bug-free.
Now, it also occurs to me that a const something-or-other could be
passed as a reference (since it's guaranteed not to change) , or that
the address of the object could be passed rather than the whole thing in
the case of a large object. Is this generally done by the compiler? Is
this one of the good reasons for using const?
The point of using const on a parameter to a function should be to let
your compiler know that the parameter shouldn't be modified during your
program. This allows you to keep your code safe and bug-free.
Now, it also occurs to me that a const something-or-other could be
passed as a reference (since it's guaranteed not to change) , or that
the address of the object could be passed rather than the whole thing in
the case of a large object. Is this generally done by the compiler? Is
this one of the good reasons for using const?