How to call a non-const function within a const function (C++)

后端 未结 7 663
天命终不由人
天命终不由人 2020-12-10 01:06

I have a legacy function that looks like this:

int Random() const
{
  return var_ ? 4 : 0;
}

and I need to call a function within that lega

7条回答
  •  醉梦人生
    2020-12-10 01:59

    Without using const casts, could you try creating a new instance of the class in the Random() method?

提交回复
热议问题