'identifier' 不能以 'specifier' 識別碼宣告
備註
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