Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-03-25 14:27:46


Is there any way to make the following work as expected:

class A {}
class B : public A { public: void f(); }
boost::smart_ptr<A> make_A() { return new B(); }

void init_module()
{
  boost::python::module_builder module("module");
  boost::python::class_builder<A> A_class(module, "A");
  boost::python::class_builder<B> B_class(module, "B");
  B_class.declare_base(A_class);
  B_class.def(B::f, "f");
  module.def(make_A, "make_A");
}

// Then in Python...
x = make_A()
x.f()

--
Rainer Deyke (root_at_[hidden])
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk