The answer is NO. The long answer is perhaps YES, provided you try to change only members marked as mutable (but not via a non-const function, that won't work at all). Or, more contriveduse an abomination like this, via a pointer to the instance (the pointer itself is may be is not changed, but what it points to can be changed without violating bitconst_cast-wise const). Or, even much more contrived, via aing const_castthis in the modifying method (this actually fits exactly your question). Example of the first (via mutable):
#include <iostream> struct Foo { mutable int x = 0; // try removing mutable and you get a compile-time error void modify_x() const { ++x; } }; int main() { const Foo foo; // we make sure we can only invoke const member functions foo.modify_x(); // can modify x since it is mutable std::cout << foo.x << std::endl; } And of the second (via pointer):
#include <iostream> struct Foo { int x = 0; void f(Foo* foo) const { ++foo->x; } void modify_x(Foo* foo) const { f(foo); // call const member function here that actually changes the instance // ++x; // this won't work } }; int main() { Foo foo; foo.modify_x(&foo); std::cout << foo.x << std::endl; } And the last (that actually directly addresses your question) - an abomination like this, using const_castconst calling function (but you have to make sure you invoke your function on non-const objects, otherwise it leads to undefined behaviour):
#include <iostream> struct Foo { int x = 0; void f() { ++x; } void modify_x() const { const_cast<Foo*>(this)->f(); // call non-const member function } }; int main() { Foo foo; std::cout << foo.x << std::endl; foo.modify_x(); std::cout << foo.x << std::endl; }