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 sorting algorithm does c++ use?

879


What is the use of pointer in c++ with example?

796


What's the most powerful programming language?

797


How do you flush a buffer in c++?

810


What are arithmetic operators?

758


Can member functions be private?

792


Can c++ be faster than c?

805


What is the standard template library (stl)?

1063


Is string data type in c++?

803


What is a flag in c++?

820


Eplain extern keyword?

780


How do I make turbo c++ full screen?

799


What are the two types of polymorphism?

797


What is a storage class used in c++?

825


What is the exit function in c++?

752