I have python embedded in a C++ application. The C++ calls python and passes it as an argument a C++ object. that object has some virtual functions and can be a base class for some derived class. How do I make boost::python understand that it's a virtual function?
consider the following:
in C++:
class Base {
public:
virtual void func();
}
class Derived {
public:
virtual void func();
}
BOOST_PYTHON_MODULE(module_api) {
class_<Base>("Base")
.def("func", &Base::func); // ?? what should I put here?
}
int main() {
//... initialization
Derived derived;
main_namespace["pyentry"](&derived);
}
in python:
def pyentry(baseref):
baseref.func() # here I want Derived::func() to be called
What am I doing wrong here?
void Base::doFunc() { this->func(); },.def("func", &Base::doFunc);