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

   CBase() { m_nValue = 0; }
   void Test() const;


   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.
void CBase::Test() const 
   const_cast< CBase * >( this )->m_nValue--;

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Зареєструйся Зараз
або Підпишись на майбутні тести