What is "mutable" keyword?

Answer Posted / roshanpr

mutable key word is used when u want to make any member
variable of a const object modifyable.

Basically when u make a object constant u cannot modify its
data members. But during the declaration of the class if a
data member is declared as mutable it can changed.

Class my
{

mutable int age;

public:

my(){age=0;}
void plusplus(int b)const
{
age+=b;
}
};

int main()
{
const my obj;
obj.plusplus(40);
}

Is This Answer Correct ?    41 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string in c++ programming?

719


Can constructor be static in c++?

760


Can c++ be faster than c?

691


What is the type of 'this' pointer?

698


What is a hash function c++?

647






How do I download c++?

651


Is main a class in c++?

640


Explain the difference between c & c++?

681


What are punctuators in c++?

763


What is the maximum combined length of command line arguments including the space between adjacent arguments?

667


What is the object serialization?

735


What is the difference between while and do while loop? Explain with examples.

688


What is a constant? Explain with an example.

631


What are the data types in c++?

605


What is difference between class and structure in c++?

723