问题遇到的现象和发生背景
对c+d和c-d的结果有疑问,代码执行过程中参数是如何传递的
问题相关代码,请勿粘贴截图
class New_int(int):
def __add__(self,other):
return int.__sub__(self,other)
def __sub__(self,other):
return int.__add__(self,other)
c = New_int(3)
c
3
d = New_int(5)
d
5
c + d
-2
-2
-2
c - d
8