Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
'lidnaam': een statisch gegevenslid met een in-class initialiser heeft een niet-vluchtig const integraal type nodig
Opmerkingen
Als u een static gegevenslid wilt initialiseren dat is gedefinieerd als volatile, niet-const of niet een integraal type, gebruikt u een liddefinitieverklaring. Ze kunnen niet worden geïnitialiseerd in een declaratie.
Example
In dit voorbeeld wordt C2864 gegenereerd:
// 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
};
In dit voorbeeld ziet u hoe u C2864 kunt oplossen:
// 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;