83. Smart Pointers-II

Question.3

Two objects hold shared_ptrs to each other:

struct A { std::shared_ptr<B> b_ptr; };
struct B { std::shared_ptr<A> a_ptr; };

auto a = std::make_shared<A>();
auto b = std::make_shared<B>();
a->b_ptr = b;
b->a_ptr = a;
// Both go out of scope...

What happens when a and b go out of scope?

Need Help? Refer to the Quick Guide below

Select Answer