Learn how to write a effective and modern code with reference to Effective Modern C++ written by Scott Meyers.
- Smart pointers
- What are smart pointers?
- unique_ptr
- shared_ptr
- weak_ptr
According to Microsoft Document, smart pointers are defined in the std
namespace in the <memory> header file.
In classic C++, programmers use raw pointer. But with this pointer, programmers have to set where the dynamically allocated object will be destroyed. So, many human error like memory leak has occured in the past.
To deal with this problem, smart pointers were introduced in C++11.