The error messages indicate that neither Derived1
nor Derived2
can be instantiated, as they are abstract classes:
Derived1
has a pure virtual function:int Base::test2(int, int)
.Derived2
has a pure virtual function:int Base::test1(int, int)
.
When either of these are exposed via boost::python::class_
, a compiler error should occur. class_
's HeldType
defaults to the type being exposed, and the HeldType
is constructed within a Python object. Hence, python::class_<Derived1, ...>
will instantiate Boost.Python templates that attempt to create an object with a dynamic type of Derived1
, resulting in the compiler error.
This error does not present itself with BaseWrap
, as BaseWrap
implements all pure virtual functions. The boost::python::pure_virtual()
function specifies that Boost.Python will raise a "pure virtual called" exception during dispatch if the function has not been overridden in either C++ or Python.