adspace


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 character terminates all character array strings a) b) . c) END

1403


Can union be self referenced?

1279


daily Routine of father

1492


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1172


What is the latest version on c++?

1217