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

后端 未结 3 1428
旧时难觅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条回答
  •  耶瑟儿~
    2021-01-31 06:54

    Your code, as written, doesn't compile. I suspect that your real PyDerivedClass doesn't really derive from PyBaseClass as if it did that last line would have to be

    (self.thisptr).SetObject(inputObject.thisptr)
    

    This would also explain the type error you're getting, which is a bug I can't reproduce.

提交回复
热议问题