[C++-sig] shared_ptr, abstract classes and inheritance
Roman Yakovenko
roman.yakovenko at gmail.com
Tue Oct 24 22:15:58 CEST 2006
On 10/24/06, Tobias Kräntzer <info at tobias-kraentzer.de> wrote:
> hello altogether,
>
> i have a problem using boost::python and boost::shared_ptr with abstract
> classes and inheritance.
>
> i am using a structure of abstract classes as interface. the implementation is
> in derived classes of the base classes.
>
> class Base { /* ..pure virtual methods.. */ };
> class Derived : Base { /* ..pure virtual methods.. */ };
>
> class Base_impl : Base { /* ..implementation gose here.. */ };
> class Derived_impl : Derived { /* ..implementation gose here.. */ };
>
> the object creation is handled with a factory which always returns a
> shared_ptr< Base >.
>
> shared_ptr< Base > factory( bool use_derived);
>
> if the factory creates a derived class i want have access to that interface.
>
> >>> base = factory( False ) # object of type Base
> >>> derived = factory( True ) # object of type Derived
>
> how can i handle this?
You did not describe the problem you actually have.
derived.bar() should work
It seems that you exported the classes "by the book".
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list