In other words, recall that member functions are implicitly passed a this-pointer when called. When you declare a member function as const, you are specifying the constness of that implicit parameter. Free and static functions cannot be declared as such because it would not make any sense; they have no implicit parameters.
In code:
Code:// Equivalent non-const functions void MyClass::foo() { // ... } void foo(MyClass * this_ptr) { // ... } // Equivalent const functions void MyClass::bar() const { // ... } void bar(const MyClass * this_ptr) { // ... }




Reply With Quote