How to remove the const attribute of a const member function

as follows:

class A {
 public:
  void const_fun() const {
    auto mutable_this = const_cast<A*>(this);
    mutable_this->val_ = 1.0;
  };

 private:
  double val_ = 0.0;
};

Guess you like

Origin blog.csdn.net/zmhzmhzm/article/details/127935574