Compiler Error C2438
'identifier' : cannot initialize static class data via constructor
A constructor is used to initialize a static member of a class. Static members must be initialized in a definition outside the class declaration.
The following sample generates C2438:
// C2438.cpp
struct X {
X(int i) : j(i) {} // C2438
static int j;
};
int X::j;
int main() {
X::j = 1;
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for