[C++-sig] Confusion about inheritance with boost.python

Noah Schwartz noah.schwartz1 at gmail.com
Tue Oct 3 00:56:18 CEST 2006


Hi,

	I am a bit confused about how to properly handle inheritance when exposing my 
C++ classes to python.

Here's my simple example:
#include <boost/python.hpp>
using namespace boost::python;

class A {
	virtual ~A() = 0;
	virtual int f() = 0;
};

struct AWrap : A, wrapper<A> {
	int f() {
		return 0;
	}
};

BOOST_PYTHON_MODULE(libnn)
{
	class_<AWrap, boost::noncopyable>("A")
		.def("f", pure_virtual(&A::f))
		;
}

However when I load my module in python I get a complaint about the undefined 
symbol A.

I think I might be a bit generally confused about this.

Thanks,
Noah



More information about the Cplusplus-sig mailing list