On 18/12/13 18:20, Timon Gehr wrote:
Well, 'const' attached to a method is simply the notation used for attaching
'const' to the implicit 'this' parameter.
Sure, but if you see a method:
struct Foo
{
const int bar() { ... }
}
... the instinctive interpretation of that is "This is a method that returns a
const int." You soon learn your mistake, but once you have, the mental
association between one form of const and the other makes sense, even if you
don't appreciate the subtlety of the fact that it's referring to the implicit
"this" parameter.
I suggest attaching const, immutable, etc. to constructors is similarly helpful
by analogy, even if it strictly speaking means using the same keyword for two
different things.