72. mutable Keyword

Question.4

A developer marks a critical member as mutable to avoid fixing a design issue:

class Motor {
   mutable int speed;  // Marked mutable to allow modification everywhere
public:
   void update() const { speed = 100; } // Should not be const!
};

Is this good use of mutable?

Need Help? Refer to the Quick Guide below

Select Answer