next up previous
Next: What are static members? Up: class and struct Previous: When should I use

How do I modify attributes in a const method?

When you have no other choice (which happens), use the keyword mutable:
struct A
{
  int           a;
  mutable int   b;
  void	f() const
  {
    a = 0; // error
    b = 0; // ok
  }
};



Alexis Angelidis (PhD) 2005-01-11