У меня есть следующий файл интерфейса SWIG (все в одном)
pyhello. я
Код: Выделить всё
%module pyhello
%{
#include
// Inline definition of my C++ class
class MyInt
{
public:
MyInt(int n) : _n(n) {}
static MyInt* create(int n) { return new MyInt(n); }
int get() const { return _n; }
private:
int _n;
};
%}
%typemap(out) MyInt, MyInt&
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79030746/call-in-python-to-a-constructor-of-a-c-class-exported-through-swig-using-a-typ[/url]