2 Oct
2007
2 Oct
'07
6:11 p.m.
Peter Dimov wrote:
In this case, you can use
struct B : A { shared_ptr<B> getB() { return dynamic_pointer_cast<B>( shared_from_this() ); } };
after making A polymorphic.
Is there any reason you couldn't use static_pointer_cast? You know for a fact that the cast to B will work, as getB is a member function of B. I think this will also remove the need to make A polymorphic.