adspace


Explain mutable storage class specifier.

Answer Posted / Alok Kumar Agmani

The 'mutable' storage class specifier is used to allow a member variable of a const object to be modified within non-const member functions. This is useful when we have a const object that contains data that can change, such as variables related to counting or timing. For example:n```nstruct counter {n int m_count;n mutable unsigned long m_last_accessed;n void increment() {n ++m_count;n m_last_accessed = std::time(nullptr);n }n};

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

daily Routine of father

1492


What character terminates all character array strings a) b) . c) END

1403


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1172


What is the latest version on c++?

1217


Can union be self referenced?

1279