3 ms·
I think the implication is that since void output(std::string const &msg); takes a const reference, that function cannot change the value of msg. What the func
by Deregibus 13y ago
I think the implication is that since void output(std::string const &msg); takes a const reference, that function cannot change the value of msg. What the function does not know is whether or not anyone else outside of the function could change that value. It doesn't know if the original creation of the object was const or not const.
The example is misleading because there isn't any reason why you would be concerned with such a distinction in this case.
- alexchamberlain 13y agoAgreed, it is completely irrelevant that it could be modified before or after.