Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'identifier' cannot be declared with 'specifier' specifier
A mutable
specifier was used in a declaration, but the specifier is not allowed in this context.
The mutable
specifier can be applied only to names of class data members, and cannot be applied to names declared const
or static
, and cannot be applied to reference members.
Example
The following sample shows how C2178 may occur, and how to fix it.
// 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