Quick A: Because shared_ptr is awesome and remembers the correct deleter to call.
Recently on SO:
Why does incomplete type of smart pointer data member and raw pointer data member have different behavior when their parent destruct?
In the following code:
smart pointer data member pImpl(class Impl) and raw pointer pc(class CAT) all are incomplete data type, there is no definition of these two classes in Widget.h ...
... For the raw pointer data member, its destuctor is not called when widget object is destructed.
While the
... Why doshared_ptrdata member, its destructor has been correctly called.shared_ptrdata member and raw data member have different behavior when the widget gets destructed?

Add a Comment
Comments are closed.