Lecture 4 - Slide 17 : 40
About use of smart pointers in C++11
Some observations about use of
shared_ptr
and
unique_ptr
Smart pointers can only be used with pointers to objects on the heap
Do not use smart pointers to objects on the stack
Pass pointers from
new T
expressions directly into constructers of smart pointers
Do not keep raw pointers in variables of their own
Avoid the creation of two or more manager objects for a single object on the heap
In other words: do not pass a given raw pointer to two or more smart pointers