Compiler Error C2750
'type' : cannot use 'new' on the reference type; use 'gcnew' instead
To create an instance of a CLR type, which causes the instance to be placed on the garbage-collected heap, you must use gcnew.
The following sample generates 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;
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for