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 iomanip c++?

831


What is void pointer in c++ with example?

849


Is c++ vector a linked list?

797


What is a rooted hierarchy?

897


What is the default access level?

849


Can you sort a set c++?

803


What is auto type c++?

878


How do you clear a set in c++?

826


What is stream and its types in c++?

796


How would you call C functions from C++ and vice versa?

851


Who was the creator of c++?

800


Why should we use null or zero in a program?

814


Should I learn c++ c?

839


Define 'std'.

945


How does atoi function work?

899