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

后端 未结 7 758
天命终不由人
天命终不由人 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:53

    you should alter your program to use/declare const correctly...

    one alternative is to use const_cast.

提交回复
热议问题