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

Can I learn c++ without c?

601


What causes a runtime error c++?

581


Why is the function main() special?

619


What are containers in c++?

567


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

3051






What does scope resolution operator do?

592


Explain what data encapsulation is in c++?

570


What is operators in c++?

565


What is a dll entry point?

560


Write about an iterator class?

611


How does java differ from c and c++?

535


Explain the use of this pointer?

634


What is the C-style character string?

600


What do you mean by function pointer?

593


what are Access specifiers in C++ class? What are the types?

626