Getting a shared pointer to a derived class when base class inherits from enable_shared_from_this
Posted
by Nikhil
on Stack Overflow
See other posts from Stack Overflow
or by Nikhil
Published on 2010-03-15T20:32:25Z
Indexed on
2010/03/19
18:11 UTC
Read the original article
Hit count: 197
I have a class B which inherits from A which in turn derives from enabled_shared_from_this
. Now, I want to get a shared pointer to B from an instance of B. shared_from_this
will return shared_ptr<A>
, not shared_ptr<B>
. Should I use boost::static_pointer_cast
here? Or is there a better way?
© Stack Overflow or respective owner