const_cast VS mutable ? any difference?

Viewed 4841

From my understanding , mutable cancels the constness of a variable

Class A {
  void foo() const {
  m_a = 5;
}
mutable int m_a;
};

But also const_cast :

void print (char * str)
{
  cout << str << endl;
}

int main () {
  const char * c = "this is a line";
  print ( const_cast<char *> (c) );
  return 0;
}

So , what changes one from the other ?

Thanks

4 Answers
Related