Cython/Python/C++ - Inheritance: Passing Derived Class as Argument to Function expecting base class

后端 未结 3 1390
旧时难觅i
旧时难觅i 2021-01-31 06:28

I am using Cython to wrap a set of C++ classes, allowing a Python interface to them. Example Code is provided below:

BaseClass.h:

#ifndef __BaseClass__
#         


        
3条回答
  •  -上瘾入骨i
    2021-01-31 07:07

    Honestly, this looks like a bug. The object you're passing in is an instance of the desired class, but it still throws an error. You may want to bring it up on the cython-users mailing list so the main developers can look at it.

    A possible workaround would be to define a fused type that represents both types of arguments and use that inside the method. That seems like overkill though.

提交回复
热议问题