What is "mutable" keyword?

Answer Posted / shakti singh khinchi

Mutable keyword is used to modify a data member of an object
which has declared as constant. for example:

class XYZ
{
public:
int i;
mutable int cc;
public:
XYZ();
};

int main()
{
const XYZ obj;
obj.cc = 100; // modify obj object's member "cc" which has
been declared as mutable.
}

Is This Answer Correct ?    16 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is map sorted c++?

745


Why do we use vector in c++?

790


What is searching?

869


How do I download c++?

746


What is private, public and protected inheritance?

824


Write about the local class and mention its use?

833


Why is c++ still used?

804


What are the differences between java and c++?

716


Define upcasting.

797


What is ctime c++?

856


describe private access specifiers?

861


What do you know about near, far and huge pointer?

800


What is decltype c++?

743


Is C++ case sensitive a) False b) Depends on implementation c) True

813


What is a manipulator in c++?

945