Which is better:
bool MyClass::someQuery() const;const bool MyClass::someQuery() const;
I've been using const bool
since I'm sure I remember hearing it's "what the int
s do" (for e.g. comparison operators) but I can't find evidence of that anywhere, mostly due to it being difficult to Google and IntelliSense not helping out any ;) Can anyone confirm that?
To me returning const
values (this isn't just about bool
) makes more sense; it'll prevent temporaries being modified, which is almost always going to be a programmer mistake. I just want something to back that up so I can extol returning const
values to my colleagues :)