What are the semantics of a const member function?

后端 未结 9 756
囚心锁ツ
囚心锁ツ 2020-12-06 16:51

I understand that the function is not allowed to change the state of the object, but I thought I read somewhere that the compiler was allowed to assume that if the function

9条回答
  •  萌比男神i
    2020-12-06 17:53

    Corey is correct, but bear in mind that any member variables that are marked as mutable can be modified in const member functions.

    It also means that these functions can be called from other const functions, or via other const references.


    Edit: Damn, was beaten by 9 seconds.... 9!!! :)

提交回复
热议问题