共用方式為


編譯器錯誤 C2178

'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