Could somebody please give me a little advice regarding const correctness within a C++ wrapper class which encapsulates some legacy C functionality.
Given the following class which partially wraps the pthread mutex API:
class Mutex {
private:
pthread_mutex_t mMutex;
public:
Mutex();
void lock();
void unlock();
bool tryLock(); };
Should the member variable mMutex and the lock(), unlock() and tryLock() methods be declared as const? From a C++ perspective, whilst none of these methods actually change the value of the object, they do appear to change the encapsulated state.
Conceptually, should "const" apply to an object's value, state or both?