C++中的智能指针

C++中有三种智能指针:std::unique_ptr、std::shared_ptr、std::wake_ptr,都在<memory>头文件定义中。 出现智能指针的缘由:C++内没有内存回收机制,程序员分配和释放经常会出错。 1.unique_ptr 在unique_ptr之前,C++98引入了auto_ptr,但在C++11标准中auto_ptr被标为遗弃;主要原因有: (1)auto_ptr
相关文章
相关标签/搜索