Shared and weak pointers are one way to solve memory leaks. When a shared pointer points at
Fantastic news! We've Found the answer you've been seeking!
Question:
Shared and weak pointers are one way to solve memory leaks. When a shared pointer points at something, it adds one to a refcount. When the pointer stops pointing at it, the refcount goes back down. When the refcount hits zero, the object gets deleted because nobody is holding on anymore. A weak pointer can also point at the same object, but it doesn't add to the refcount. When the object gets deleted by the final shared pointer letting go, all weak pointers are cleared to null.
a) What do you think the class definitions for SharedPtr and WeakPtr look like? Make sure to explain how the properties and methods you list make the system work.
Related Book For
Modern Systems Analysis And Design
ISBN: 9780134204925
8th Edition
Authors: Joseph Valacich, Joey George
Posted Date: