The Cython documentation shows how to declare existing C ++ classes with overloaded methods.
However, if I define my own cppclass with an overloaded method ...
cdef cppclass point: float x, y point(): this.x = 0 this.y = 0 float sum(): return this.x + this.y float sum(int z): # COMPILE ERROR return this.x + this.y + z
... I get
Function signature does not match previous declaration
Overloading the constructor gives the same error there:
cdef cppclass point: float x, y point(): this.x = 0 this.y = 0 point(float X, float Y): # COMPILE ERROR this.x = X this.y = Y float sum(): return this.x + this.y
Am I doing it wrong or is this feature missing?
Update: By default, the default arguments are also unsuitable:
cdef cppclass point: float x, y point(float X=0, float Y=0): this.x = X this.y = Y float sum(): return this.x + this.y cdef float use_point(): cdef point p p = point(1, 2) return p.sum()
... passes Cython, but crashes with the C ++ compiler ("wrong number of arguments")
source share