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

What is a local variable?

865


What is #include cstdlib in c++?

927


How can you link a c program with a c function?

818


Array base access faster or pointer base access is faster?

2074


Why do we need pointers?

773


Why is main an int?

760


Is eclipse good for c++?

808


Why we use #include iostream in c++?

794


Write about the stack unwinding?

864


How would you obtain segment and offset addresses from a far address of a memory location?

850


Can I learn c++ without learning c?

787


What is the difference between a declaration and a definition?

836


Differentiate between a template class and class template in c++?

866


Can notepad ++ run c++?

754


Can you please explain the difference between overloading and overriding?

857