Saturday, December 5, 2009

Access non const member varible inside a const member function

class MyClass {
public:
      void F() const {
        const_cast(this)->c = 10;
        //c = 10;
      }
    private :
      int c;

}; 

Other solution is mutable.

0 comments:

Post a Comment