shared_ptr为智能指针,今天一次在使用shared_ptr时,错误的将其初始化方式写为shared_ptr<T> test = shared_ptr<T>(),随后导致崩溃

正确做法是shared_ptr<T> test = make_shared<T>() 或shared_ptr<T> test = shared_ptr<T>(new T);切记  智能指针使用也不要忘记分配内存!!!

相关文章:

  • 2021-07-04
  • 2021-07-05
  • 2021-11-03
  • 2021-04-29
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2021-12-31
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案