[C++-sig] Re: call_f(Derived) did not match C++ signature

David Abrahams dave at boost-consulting.com
Thu Jun 10 18:46:18 CEST 2004


Shin-ichi MORITA <shin1_morita at yahoo.co.jp> writes:

> Sorry, I sent incomplete message.
>
>> Writing this, I've just found the cause.
>> I exposed Base in foo.cc:
>
> class_<Base, BaseWrap, boost::noncopyable>("Base",
> no_init);
>
> and defined Derived in test_foo.py:
>
> class Derived(Base):
>     def __init__(self):
>         pass # because I exposed with no_init.
>     def f(self):
>         return 42
>
> This is wrong.
> Next I removed "no_init" and "__init__" above like this:
>
> class_<Base, BaseWrap, boost::noncopyable>("Base");
>
> class Derived(Base):
>     # Base.__init__ will be called.
>     def f(self):
>         return 42
>
> Finally I got *passed*.
>
> Base.__init__ must be called to initialize Derived
> instance correctly, is this right?

Correct.

> If so, I think that "no_init" is not for abstract base
> class, but just for only noncreatable class.

Correct, though I hope to fix that one day.
>
> Why dose this page in the tutorial uses "no_init" to
> explain abstract base class?
> http://boost.org/libs/python/doc/tutorial/doc/class_virtual_functions.html

Because it's wrong, I guess :(

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list