[C++-sig] Wrapping a class whose constructor takes a pointer to an abstract class

David Abrahams dave at boostpro.com
Mon Sep 22 19:59:49 CEST 2008


on Fri Sep 19 2008, Jean-Sébastien Guay <jean-sebastien.guay-AT-cm-labs.com> wrote:

>     class_<ShapeDrawable, bases<Drawable>,
>            ref_ptr<ShapeDrawable> >("ShapeDrawable")
>         .def(init<Shape, TessellationHints>())
>     ;
>
> The first three classes wrap correctly, but the fourth fails with a compiler
> error saying it cannot instantiate abstract class Shape. OK, I understand that,
> but what can I do about it?

I can't promise that this is enough to make everything work, but you
could start by making the init signature match your constructor
signature:

     class_<ShapeDrawable, bases<Drawable>,
            ref_ptr<ShapeDrawable> >("ShapeDrawable")
         .def(init<Shape*, TessellationHints>())
                        ^
here--------------------^

It will at least compile, then!

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



More information about the Cplusplus-sig mailing list