Search code examples
pythoncython

How do I use a base class constructor for a cppclass in Cython?


Suppose I have

cdef extern from "foo.h":
    cppclass Base:
        Base(int i)  # only constructor

cdef cppclass Child(Base):
    __init__():
        pass

How do I make sure that Base(int) is called? The generated C++ for Child needs to initialize Base in its constructor's initializer list; can I do that with Cython?


Solution

  • I don't think it's currently possible.

    The ability to define C++ classes within Cython (as opposed to wrapping existing C++ classes) is currently somewhat underdeveloped and undocumented (largely because there's a lot that you can't do).