
Hi! I have a polymorphic class in c++ like: class Example { public: void do_something() = 0; void do_something_more {} } This is wrap like: #include <boost/python.hpp> using namespace boost::python; struct ExampleWrap : Example, wrapper<Example> { void do_something() { this->get_override("do_something")(); } }; and finally: BOOST_PYTHON_MODULE(test) { class_<ExampleWrap, boost::noncopyable>("Example") .def("do_something", pure_virtual(&Window::do_something)) .def("do_something_more", &Window::do_something_more) ; } This compiles fine, the python code that work looks like: class Example(test.Example) def do_something(self): ...some code... e = Example() e.do_something_more() The python code that doesn't work looks like: class Example(test.Example) def __init__(self): ..some code... def do_something(self): ...some code... e = Example() e.do_something_more() This generates the error: e.do_something_more() Boost.Python.ArgumentError: Python argument types in Example.do_something_more(Example) did not match C++ signature: do_something_more(Example {lvalue}) How can I fix this? I really need to define a constructor in python class that inherit from the c++ Example class. /Fredrik ----------------------------------------------- This mail was sent through www.lulea.cc

Fredrik Wikström <fredrik.wikstrom@lulea.cc> writes:
Hi!
I have a polymorphic class in c++ like:
class Example { public: void do_something() = 0; void do_something_more {}
Illegal C++. Missing argument list. What did you really send to the compiler?
}
How can I fix this? I really need to define a constructor in python class that inherit from the c++ Example class.
Make sure you don't forget to call the test.Example.__init__(self). That creates the C++ ExampleWrap instance, without which you can't invoke any member functions. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Fredrik Wikström