编译器错误 C2750

“type”:不能对引用类型使用“new”;请改用“gcnew”

若要创建 CLR 类型的实例(该操作会将该实例置于垃圾回收堆),必须使用 gcnew

以下示例生成 C2750:

// C2750.cpp
// compile with: /clr
ref struct Y1 {};

int main() {
   Y1 ^ x = new Y1;   // C2750

   // try the following line instead
   Y1 ^ x2 = gcnew Y1;
}