Explain mutable storage class specifier.



Explain mutable storage class specifier...

Answer / 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

More C++ General Interview Questions

What is a class template in c++?

1 Answers  


Copy Linked List using recursive function?

2 Answers   Persistent,


How do you clear a buffer in c++?

1 Answers  


Explain terminate() function?

1 Answers  


What is the function of I/O library in C++ ?

1 Answers   HCL,


Explain public, protected, private in c++?

1 Answers  


1.what is the difference between software & package &application.

1 Answers   Infosys,


What is a node class?

1 Answers  


Explain how a pointer to function can be declared in C++?

1 Answers  


What are the techniques you use for debugging?

1 Answers   Adtran,


structure that describe a hotel with name, address,rooms and number of rooms

2 Answers  


Why c++ is so important?

1 Answers  


Categories