How does const after a function optimize the program?

前端 未结 6 2082
星月不相逢
星月不相逢 2021-01-31 05:29

I\'ve seen some methods like this:

void SomeClass::someMethod() const;

What does this const declaration do, and how can it help optimize a prog

6条回答
  •  南旧
    南旧 (楼主)
    2021-01-31 05:52

    It prevents someMethod from altering any member variable of an object of that class.

提交回复
热议问题