Intermediate C++
Q58 / 100

What is the purpose of weak_ptr?

Correct! Well done.

Incorrect.

The correct answer is B) A non-owning reference to a shared_ptr-managed object that doesn't prevent deletion, breaking reference cycles

B

Correct Answer

A non-owning reference to a shared_ptr-managed object that doesn't prevent deletion, breaking reference cycles

Explanation

weak_ptr does not increase the reference count. Convert to shared_ptr with lock() to access the object. Used to break shared_ptr reference cycles.

Progress
58/100