On 07/23/2010 03:09 PM, Lutz Maibaum wrote:
Dear all,
I am totally new to Boost.Python, and I am going through the tutorial to get up
to speed. I apologize if this is a very obvious question.
<snip>
class Base {
public:
virtual int f() = 0;
};
class Derived : public Base {
public:
int f() {return 1;}
};
class BaseWrap : public Base, public wrapper<Base> {
public:
int f() {return this->get_override("f")();}
};
int func(Base& b) {
return b.f();
}
BOOST_PYTHON_MODULE(foo) {
class_<Derived, bases<Base> > ("Derived")
.def("f",&Derived::f);
class_<BaseWrap, boost::noncopyable>("Base")
.def("f", pure_virtual(&Base::f));
def("func", func, "Calls the method f of its argument");
}
Try this:
BOOST_PYTHON_MODULE(foo) {
class_<BaseWrap, boost::noncopyable>("Base")
.def("f", pure_virtual(&Base::f));
class_<Derived, bases<Base> > ("Derived")
.def("f",&Derived::f);
def("func", func, "Calls the method f of its argument");
}
(just swap the order of the class_ statements)
Jim Bosch
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig