Quick A: Inherit from enable_shared_from_this
.
Recently on SO:
Cast 'this' to std::shared_ptr
I have a method on a class to make a particular instance an "active" instance:
void makeActive() { activeInstance = this; }However it doesn't work since
activeInstance
has typestd::shared_ptr< ClassName >
. How can I cast this tostd::shared_ptr<ClassName>
?
Add a Comment
Comments are closed.