When reading tutorials and code written in C++, I often stumble over the const keyword.
I see that it is used like the following:
const
The first function example is more-or-less meaningless. More interesting one would be:
void myfunc( const char *x );
This tells the compiler that the contents of *x won't be modified. That is, within myfunc() you can't do something like:
strcpy(x, "foo");
The second example, on a C++ member function, means that the contents of the object won't be changed by the call.
So given:
class {
int x;
void myfunc() const;
}
someobj.myfunc() is not allowed to modify anything like:
x = 3;