[C++-sig] shared_ptr, abstract classes and inheritance
Tobias Kräntzer
info at tobias-kraentzer.de
Wed Oct 25 22:35:56 CEST 2006
Am Dienstag, 24. Oktober 2006 23:28 schrieb Tobias Kräntzer:
> > Does it help?
>
> unfortunately not.
> the same behavior as before.
Temporally I've made a workaround:
I changed the factory to:
list factory( bool use_derived )
{
list result;
if ( !use_derived )
{
Base::Ptr pt( new Base_impl() );
result.append( pt );
}
else
{
Derived::Ptr pt( new Derived_impl() );
result.append( pt );
};
return( result );
};
an write an new factory in Python:
>>> import test
>>> _old_factory = test.factory
>>>
>>> def _new_factory( derived ):
... return _old_factory( derived )[0]
>>> test.factory = _new_factory
>>>
>>> test.factory( True )
<test.Derived object at 0xb7bbf994>
>>> test.factory( False )
<test.Base object at 0xb7bd056c>
>>> test.factory( True ).bar()
'Derived bar'
I will focus on a solution to the problem later.
But at the moment, thanks for help.
More information about the Cplusplus-sig
mailing list