Kompilatorfel C3883

"medlem": en initont statisk datamedlem måste initieras

Anmärkningar

En variabel som markerats med initonly initierades inte korrekt.

Example

I följande exempel genereras C3883:

// C3883.cpp
// compile with: /clr
ref struct Y1 {
   initonly
   static int staticConst1;   // C3883
};

I följande exempel visas en möjlig lösning:

// C3883b.cpp
// compile with: /clr /c
ref struct Y1 {
   initonly
   static int staticConst2 = 0;
};

I följande exempel visas hur du initierar i en statisk konstruktor:

// C3883c.cpp
// compile with: /clr /LD
ref struct Y1 {
   initonly
   static int staticConst1;

   static Y1() {
      staticConst1 = 0;
   }
};