[C++-sig] Re: wrapping class with pure virtual function & non-default constructor

David Abrahams dave at boost-consulting.com
Sat Mar 26 21:13:10 CET 2005


Faheem Mitha <faheem at email.unc.edu> writes:

> Hi,
>
> Please consider the following variation of the example in the
> tutorial. The main difference here is that the class that is being
> wrapped has a non-default destructor.
>
> Without a destructor declared in BaseWrap, this gives the error
>
> error: base `World' with only non-default constructor in class without
> a constructor

Surely not.  Where could the identifier `World' possibly come from in
that code?

The code compiles for me.  I don't think what the error is talking
about is really an error in C++, anyway.  Are you using -Wall to turn
warnings into errors?

> Adding a default constructor to the wrapper class makes the error go away, eg.
>
> BaseWrap():Base(0){}
>
> I can't find an example of this anywhere. I've looked at the docs, but
> don't understand what is going on well enough. So, I'm asking here.
> Is this Ok, and can I use any default constructor for the wrapper
> class without it making any difference?

The answer to your problem, whatever it may be, doesn't really have
anything to do with Boost.Python.

> One other thing. Am I correct in thinking that wrapping the base class
> in this fashion is necessary if I want to wrap the derived classes?

No, it's not.

> Clarifications appreciated. I'm not subscribed, so please cc me at
> faheem at email.unc.edu if possible.
>
> Thanks.                                                 Faheem.
>

<snip code not containing the identifier `World' anywhere>

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list