编译器错误 C2396
“your_type::operator'type'”:CLR 或 WinRT 用户定义的转换函数无效。 必须转换自或转换为:“T^”、“T^%”或“T^&”,其中 T =“your_type”
Windows 运行时或托管类型中的转换函数没有至少一个类型与包含转换函数的类型相同的参数。
下面的示例生成 C2396,并演示如何修复此错误:
// C2396.cpp
// compile with: /clr /c
ref struct Y {
static operator int(char c); // C2396
// OK
static operator int(Y^ hY);
// or
static operator Y^(char c);
};