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
What is string in c++ programming?
Can constructor be static in c++?
Can c++ be faster than c?
What is the type of 'this' pointer?
What is a hash function c++?
How do I download c++?
Is main a class in c++?
Explain the difference between c & c++?
What are punctuators in c++?
What is the maximum combined length of command line arguments including the space between adjacent arguments?
What is the object serialization?
What is the difference between while and do while loop? Explain with examples.
What is a constant? Explain with an example.
What are the data types in c++?
What is difference between class and structure in c++?