Dela via


Kompilatorvarning (nivå 1) C4965

implicit låda med heltal 0; använda nullptr eller explicit cast

Anmärkningar

Visual C++ har implicit boxning av värdetyper. En instruktion som resulterade i en null-tilldelning med managed extensions för C++ blir nu en tilldelning till en inramad int.

Mer information finns i Boxning.

Example

I följande exempel genereras C4965.

// C4965.cpp
// compile with: /clr /W1
int main() {
   System::Object ^o = 0;   // C4965

   // the previous line is the same as the following line
   // using Managed Extensions for C++
   // System::Object *o = __box(0);

   // OK
   System::Object ^o2 = nullptr;
   System::Object ^o3 = safe_cast<System::Object^>(0);
}