Smart pointers
Smart pointers enable automatic, exception-safe, object lifetime management.
Defined in header
Pointer categories
1. unique_ptr (C++11) smart pointer with unique object ownership semantics
2. shared_ptr (C++11) smart pointer with shared object ownership semantics
3. weak_ptr (C++11) weak reference to an object managed by std::shared_ptr
4. auto_ptr (until C++17) smart pointer with strict object ownership semantics
定义智能指针的通用技术是使用计数。
找个时间好好看看c++ prime plus
智能指针详解
本文介绍了C++中的智能指针概念及其不同种类,包括unique_ptr、shared_ptr、weak_ptr及auto_ptr(已被弃用)。智能指针通过使用计数等技术实现了对象生命周期的自动管理,并确保了异常安全性。
1203

被折叠的 条评论
为什么被折叠?



