Wrapping classes with pure virtual functions

Chris Lambacher chris at kateandchris.net
Sun Dec 17 11:11:22 EST 2006


On Thu, Dec 14, 2006 at 01:57:10PM -0800, gabriel.becedillas at gmail.com wrote:
> Hi,
> I'm having problems wrapping a hierarchy of classes, actually having
> problems wrapping the base class. I don't need to use the WrapClass
> mechanism since I don't want to override classes in Python. My code
> boils down to:
> 
> class Base
> {
> public:
> 	virtual ~Base()
> 	{}
> 
> 	virtual void f() = 0;
> };
> 
> class Derived :
> 	public Base
> {
> public:
> 	virtual void f()
> 	{}
> 
> 	void g()
> 	{}
> };
> 
> int main()
> {
> 	boost::python::class_<Base> class_base("Base");
Why are you trying to make this type visible to python?  It is pure virtual,
you can never instantiate it.
> 	boost::python::class_<Derived> class_derived("Derived");
> 	return 0;
> }
> 
> The first line inside main (the one exporting Base) is causing the
> compile time error:
> error C2259: 'Base' : cannot instantiate abstract class...
> The probem seems to be that struct value_holder<Base> holds a Base
> member instance by value, and this is not possible since Base can't be
> instantiated.
> I'm using Visual Studio 2005 and boost 1.33.1.
> Thanks
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list