I\'ve seen some methods like this:
void SomeClass::someMethod() const;
What does this const declaration do, and how can it help optimize a prog
It allows you to call the class member function on const objects:
class SomeClass
{
public:
void foo();
void bar() const;
}
SomeClass a;
const SomeClass b;
a.foo(); // ok
a.bar(); // ok
b.foo(); // ERROR -- foo() is not const
b.bar(); // ok -- bar() is const
There's also the volatile qualifier for use with volatile objects, and you can also make functions const volatile for use on const volatile objects, but those two are exceedingly rare.