Megosztás a következőn keresztül:


C2864-fordítási hiba

"tag-név": az osztályon belüli inicializálóval rendelkező statikus adattagnak nem változékony const integráltípussal kell rendelkeznie

Megjegyzések

A static, volatile, nem-const vagy nem integrált típusként definiált adattag inicializálásához használjon tagdefiníciós utasítást. Deklarációban nem inicializálhatók.

Example

Ez a példa c2864-et hoz létre:

// 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
};

Ez a példa a C2864 javítását mutatja be:

// 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;