How does const after a function optimize the program?

前端 未结 6 1914
星月不相逢
星月不相逢 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:42

    It tells the compiler that the method has no effect on the classes state; you can't assign to anything in it. Have a look at the C++ FAQ Lite 18.10.

提交回复
热议问题