Answers for "call non-const method from const method"

C++
0

how to use a non const function from a const function

struct A
{
    int i=0;
	void foo() const
    {
      const_cast<A&>(*this).func();
    }
  	void func()
    {
      i++;
    }
};
Posted by: Guest on June-01-2021

Browse Popular Code Answers by Language