[C++-sig] downcasting problems

David Abrahams dave at boostpro.com
Fri Oct 10 20:41:17 CEST 2008


on Mon Sep 29 2008, "Renato Araujo" <renatox-AT-gmail.com> wrote:

> Hi all,
>
> After some test I got this working but with some extra code. I created
> 2 wrapper classes to Shape and Circle like that:
>
> ===========
> wrapper code:
> ===========
> class ShapeWrapper : public Shape, public wrapper<Shape>
> {
> ....
> };
>
> class CircleWrapper : public Cirlce, public wrapper<Circle>
> {
> .....
> };
>
> and used this classes in boost code. And all works fine.
> But is this the best way to do this?? 

That is the best way to wrap polymorphic classes if you want to be able
to override their C++ virtual functions in Python.

> I always need create theses
> wrapper class??

I don't understand your question, sorry.

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



More information about the Cplusplus-sig mailing list