What's the use of const here

前端 未结 7 1856
借酒劲吻你
借酒劲吻你 2021-01-21 13:09

in

int salary() const { return mySalary; }

as far as I understand const is for this pointer, but I\'m not sure. Can any one tell me what is the us

7条回答
  •  臣服心动
    2021-01-21 13:24

    It means that function can be called on a const object; and inside that member function the this pointer is const.

提交回复
热议问题