2021年11月29日

智能指针注意的坑

摘要: 1.同一普通指针不能同时为多个 shared_ptr 对象赋值,否则会导致程序发生异常。例如: int* ptr = new int; std::shared_ptr<int> p1(ptr); std::shared_ptr<int> p2(ptr);//错误. 容易引起double delete 阅读全文

posted @ 2021-11-29 12:03 zhangkele 阅读(622) 评论(0) 推荐(0) 编辑

导航