如果之前有人问过这个问题,我深表歉意。我的搜索结果没有出现类似的问题。
这是一个概念性的问题。根据MSDN以及其他人:
A constant member function cannot modify any data members or call any member functions that aren't constant
为什么允许我们从 const 方法访问静态成员变量?
最佳答案
因为它们不是对象的一部分。
关于c++ - Const 方法访问静态变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4187746/