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 a c++ vector?
Differentiate between C and C++.
What c++ library is string in?
Why do we need constructors in c++?
How to declare an array of pointers to integer?
How many types of comments are there in c++?
What is recursion?
What is abstraction c++?
What are static and dynamic type checking?
How the programmer of a class should decide whether to declare member function or a friend function?
How many different levels of pointers are there?
What is the use of register keyword with the variables?
What are exceptions c++?
Can I learn c++ without knowing c?
What are the advantages of early binding?