I have created a class Hello.h
like below:
#include <string>
class Hello {
public:
Hello() {};
std::string greet() {
cout<<"HelloWorld"<<endl;
};
};
and I had using SWIG exported this class as a python module and get two files: Hello.py
and _Hello.so
, I can import this module in python env and call greet()
method successfully as below:
import Hello
a = Hello.Hello()
a.greet()
My problems is that I had created some Hello
object in C++, say objectHello
, and I want to call objectHello
's method in python through the exported module, below is what I would like to do:
import Hello
a = Hello.Hello() // My idea is that how to change this line when "a" is created in C++, how to pass it to python and thus I can call it's method in python env
a.greet()
this case is very simple, in real case, there may be many parameters for my C++ methods. How can I do to achieve that, or convince me if this is a wrong direction, can someone give me some tips on this, thanks in advance.