How can I use C++ class in Python?

后端 未结 3 1839
滥情空心
滥情空心 2020-12-23 09:26

I have implemented a class in C++. I want to use it with Python. Please suggest step by step method and elaborate each step. Somthing like this...



        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 10:12

    ctypes is good. It is really easy to use, and it comes standard with Python. Unfortunately it can only talk to shared libraries (Unix) or DLLs (Windows) that have a C-style interface, which means you can't directly interface to a C++ object. But you could use a handle system where a handle refers to a particular object.

    >>> getInt(h)
    12
    

    I think that is simple, easy to understand, and doesn't require extra libraries.

提交回复
热议问题