'member-name': 클래스 내 이니셜라이저가 있는 정적 데이터 멤버에는 비휘발성 const 정수 계열 형식이 있어야 합니다.
설명
정수 형식이 아니거나 정수 형식으로 staticvolatile정의된 데이터 멤버를 초기화 const 하려면 멤버 정의 문을 사용합니다. 선언에서는 초기화할 수 없습니다.
예시
이 예제에서는 C2864를 생성합니다.
// C2864.cpp
// compile with: /c
class B {
private:
int a = 3; // OK
static int b = 3; // C2864
volatile static int c = 3; // C2864
volatile static const int d = 3; // C2864
static const long long e = 3; // OK
static const double f = 3.33; // C2864
};
이 예제에서는 C2864를 수정하는 방법을 보여줍니다.
// C2864b.cpp
// compile with: /c
class C {
private:
int a = 3;
static int b; // = 3; C2864
volatile static int c; // = 3; C2864
volatile static const int d; // = 3; C2864
static const long long e = 3;
static const double f; // = 3.33; C2864
};
// Initialize static volatile, non-const, or non-integral
// data members when defined, not when declared:
int C::b = 3;
volatile int C::c = 3;
volatile const int C::d = 3;
const double C::f = 3.33;