Is it possible, without using the mutable keyword for the m_nValue member variable of the CBase class, to change its value inside the constant function Test?
class CBase
{
public:
CBase() { m_nValue = 0; }
void Test() const;
private:
int m_nValue;
};
Technically, there is such an opportunity. BUT! This is not recommended, as the class user, looking at the class interface, does not expect such actions from void CBase::Test() const. This is essentially a cheat.
Login in to like
Login in to comment