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 the difference between an external iterator and an internal iterator?
What is an adaptor class in c++?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What is a class template?
What is a template in c++?
Explain object slicing in c++?
Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL
What are the five basic elements of a c++ program?
What is pointer to array in c++?
What is a block in c++?
Is c# written in c++?
Why is the function main() special?
What is a try block?
What does floor mean in c++?
What is rvalue?