在D1中使用Tango:
class C
{
private int j;
public int opBinary(char[] op: "+") (ref C x) { return 1; }
public int opBinary(char[] op: "+") (C x) { return 3; }
}
int opBinary(char[] op: "+") (ref C x, ref C y) { return 2; }
int opBinary(char[] op: "+") (C x, C y) { return 2; }
void main() {
C a = new C;
C b = new C;
int j = a + b;
}
"incompatible types"
最佳答案
在D1中,使用opBinary等的模板化运算符重载不起作用。您需要使用opAdd, opSub, etc.
https://stackoverflow.com/questions/9766279/
相关文章:
winforms - C++ CLI KeyDown::raise 错误 error C3767 候
c# - 如何修复显示 “The type or namespace name X does not
python - 我类的数组给我一个错误……AttributeError : 'set' objec
objective-c - 运行奇怪的错误运行 objective-c 代码
c# - 'System.Data.Objects.ObjectContext'不包含带有0个参数的
perl - 使用中间变量访问电子表格::Read sheets时出错