Hi!
In C++ you can overload functions and constructors. For example if I have a
class that represents a complex number, than it would be nice if I can
write two seperate constructors
class Complex:
def __init__(self):
self.real=0
self.imag=0
def __init__self(self,r,i):
self.real=r
self.imag=i
How would I do this in python?
And by the way, is it possible to overload operators like +,-,*?
def operator+(self,complex2):
Complex res
res.real=self.real+complex2.real
res.imag=self.imag+complex2.imag
return res
thanks!