Call a non-const member function from a const member function

后端 未结 7 1693
情深已故
情深已故 2020-12-29 06:15

I would like to know if its possible to call a non-const member function from a const member function. In the example below First gives a compiler error. I understand why it

相关标签:
7条回答
  • 2020-12-29 07:08

    By the definition of const, a function should not modify the state of an object. But if it calls another non-const member, the object's state might get changed, so it's disallowed.

    I know you said you didn't want to hear about this, but I think it's important for others that happen upon the question.

    0 讨论(0)
提交回复
热议问题