“object type”: 在创建托管或 WinRT 类的实例时不允许使用位置参数
创建托管类型或 Windows 运行时类型的对象时,不能使用运算符 ref new、gcnew 或 new 的位置形式。
下列示例生成 C3828 并演示如何修复此错误:
// C3828a.cpp
// compile with: /clr
ref struct M {
};
ref struct N {
static array<char>^ bytes = gcnew array<char>(256);
};
int main() {
M ^m1 = new (&N::bytes) M(); // C3828
// The following line fixes the error.
// M ^m1 = gcnew M();
}