Practice ยท 2 of 2
shared_ptr lifetime counters
Implement struct SharedProbe with a static alive() counter (constructor increments, destructor decrements) and the free function int probe_lifetimes() that: creates a shared_ptr<SharedProbe>, copies it, lets the copy go out of scope in an inner block, then resets the original โ returning alive() measured after all of that. Correct code returns 0; the test proves both the copy and the reset released.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: shared/weak practice