[C++-sig] deriving in python from a C++ base class

Stefan Seefeld seefeld at sympatico.ca
Wed Jul 2 05:14:57 CEST 2003


Ralf W. Grosse-Kunstleve wrote:
> --- Stefan Seefeld <seefeld at sympatico.ca> wrote:
> 
>>class MyWorld(World):
>>     def __init__(self):
>>         self.set('hi there')
>>         print self.greet()
> 
> 
> I think you have to call World.__init__() before you can use the instance.
> Here is more information:
> 
> http://www.boost.org/libs/python/doc/PyConDC_2003/bpl.html#inheritance

thanks, that works !

I still have a question, though:

The reason I missed that was that in my real code I initialized the class_<>
with a no_init argument, as that was declared to be the way to make the (C++)
class non-instantiable. However, even though I only want subclasses to be
instantiated, I of course do need to initialize the base class (i.e. run
its constructor).

How should I do that, then ?

Thanks again,
		Stefan





More information about the Cplusplus-sig mailing list