Compiler Error C2178
'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
Athugasemdir
https://aka.ms/ContentUserFeedback.
Væntanlegt: Á árinu 2024 munum við hætta með GitHub-mál sem ábendingaleið fyrir efni og skipta því út fyrir nýtt ábendingakerfi. Frekari upplýsingar er að finna hér:Senda inn og skoða endurgjöf fyrir