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

Explain the difference between c++ and java.

650


Which bitwise operator is used to check whether a particular bit is on or off?

592


What do you mean by funtion prototype?

592


Why are pointers not used in c++?

628


Write a function to find the nth item from the end of a linked list in a single pass.

571






Explain the operation of overloading of an assignment operator.

698


What do you mean by storage classes?

797


What does flush do c++?

558


Why c++ is the best language?

594


What is the use of c++ programming language in real life?

569


What is the difference between structures and unions?

585


Write about the role of c++ in the tradeoff of safety vs. Usability?

604


What are formatting flags in ios class?

610


What is command line arguments in C++? What are its uses? Where we have to use this?

581


Which bit wise operator is suitable for checking whether a particular bit is on or off?

607