[C++-sig] Polymorphism with injected constructor...

Stefan Seefeld seefeld at sympatico.ca
Thu Jan 5 21:16:59 CET 2006


Alex Mohr wrote:

> from Test import *
> class Derived(Base):
>      def Func(self):
>          return 'Python Func'

> Again, the test works correctly if I comment out the injected 
> constructor.  Can anyone explain why this happens?

Did you try adding a constructor to the Derived class
that explicitely calls Base.__init__ ?

I'm not sure I completely understand the python object model,
in particular, the relationship between classes and their
base classes as far as object layout is concerned, but
I would imagine that a function returning a new base class
instance can't really be used to initialize a base class
of a derived instance. Just a guess...

Regards,
		Stefan



More information about the Cplusplus-sig mailing list