分享方式:


編譯器警告 (層級 1) C4965

整數 0 的隱含方塊;使用 nullptr 或明確轉換

Visual C++ 功能實值型別的隱含 Boxing。 使用 C++ 的 Managed Extensions 產生 Null 指派的指令現在會變成 Boxed int 的指派。

如需詳細資訊,請參閱 Boxing中定義的介面的私用 C++ 專屬實作。

範例

下列範例會產生 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);
}