不能使用“specifier”说明符声明“identifier”
注解
声明中使用了 mutable 说明符,但在此上下文中不允许使用说明符。
mutable 说明符仅可应用于类数据成员的名称,不能应用于声明为 const 或 static 的名称,也不能应用于引用成员。
示例
以下示例演示 C2178 是如何发生的,以及如何解决此问题。
// C2178.cpp
// compile with: cl /c /W4 C2178.cpp
class S {
mutable const int i; // C2178
// To fix, declare either const or mutable, not both.
};
mutable int x = 4; // C2178
// To fix, remove mutable keyword