There are three smart pointers, auto_ptr (deprecated), unique_ptr, shared_ptr.
Smart pointers can automatically track dynamic memory, automatically released when it expired.
One, shared_ptr
A new object is created, and not applicable to new [] object created,
for the case of sharing a plurality of address pointers.
#include<memory>
std::shared_ptr<int> int_ptr=new int;
//std::shared_ptr<int> int_ptr(new int);
二、unique_ptr
For a case where just a memory address pointer to the last,
while pointing unique_ptr new [] version.
other
Ps is a smart pointer as the object, it may be:
Dereference * ps
access structure members ps-> index
will assign it to the same type of conventional pointer
unique_ptr when the right value can be assigned shared_ptr
when unique_ptr unique_ptr assigned to another, requires the use of a mobile constructor std :: move ()