I have a
class A: public std::enable_shared_from_this<A>{....}
class B: public A{....}
later in code, I'm doing this:
std::shared_ptr<A> Construct(....){
class_field=std::make_shared<B>(...);
return class_field->shared_from_this();
}
With this code, I want to make sure that the object of B gets destroyed once current class is destroyed, as well as when the object in client function goes out of scope.
Is this correct way to handle this? Is there a better way to get shared_ptr from shared_ptr?