[C++-sig] shared_ptr, abstract classes and inheritance

Tobias Kräntzer info at tobias-kraentzer.de
Tue Oct 24 22:40:11 CEST 2006


Am Dienstag, 24. Oktober 2006 22:15 schrieb Roman Yakovenko:
> You did not describe the problem you actually have.

sorry ;-)

if i call the factory i only get the base interface not the derived.

>>> import test
>>> test.Base.create( False )
<test.Base object at 0xb7d55df4>
>>> test.Base.create( True )
<test.Base object at 0xb7d55e2c>
>>>
>>> d = test.Base.create( True )
>>> d.bar()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'Base' object has no attribute 'bar'
>>> d.__class__ = test.Derived
>>> d
<test.Derived object at 0xb7d55df4>
>>> d.bar()
'Derived bar'


. . . tobias



More information about the Cplusplus-sig mailing list