编译器错误 C2394

type::operator operator”:CLR/WinRT 运算符无效。 至少一个参数必须具有以下类型:“T^”、“T^%”、“T^&”,其中 T = 'type'

注解

Windows 运行时或托管的类型中的一个运算符没有至少一个类型与运算符返回值的类型相同的参数。

Example

以下示例生成 C2394:

// C2394.cpp
// compile with: /clr /c
ref struct Y {
   static Y^ operator -(int i, char c);   // C2394

   // OK
   static Y^ operator -(Y^ hY, char c);
   // or
   static Y^ operator -(int i, Y^& rhY);
};