They are both correct.
A const member function can not alter the state of the object.
- This means it can read (but not modify) all member variables.
- This also means it can only call other const member functions
Other methods that guarantee not to change the state of the object.
Above James also mentions mutable members.
So I should also cover those here.
A mutable member variable is a variable that is not part of the state of the object (the compiler does not consider it part of the objects state). You should also treat it this way. Any member variable that holds state information about the object should NOT be marked mutable. You should only use it to hold temporary information that can be re-constructed from the objects state.
A simple example is a date-time object. Where the object has a method that converts the data/time into a readable string format. This string may be cached in the object in a mutable member for efficiency (so that you don't need to repeatedly build the string). But the string is not part of the object state (because it can be built from other members).
Also James mentions above casting away constness using const_cast.
Except under very special situations where you know the object CAN NEVER BE const doing this is considered universally a bad idea. As it leads directly to undefined behavior. If you find yourself needing to cast away constness then something very wrong in the design has happened in your program.
In fact I can only think of one situation where it happens normally. And then I am unwilling to commit it to code without first going and doing research to make sure I don't look silly.