文章目录
前言
`C++11 概念智能指针
一、智能指针是什么?
将原始指针封装为对象,在对象销毁时调用析构释放内存,主要使用shared_ptr,因为支持赋值拷贝。
二、使用步骤
1.使用get()函数获取 原始指针
``
//float* testDataPtr = new float[xgboostTestData.channels()];
std::unique_ptr<float[]> testDataPtr(new float[xgboostTestData.channels()]);
memcpy(testDataPtr.get(),xgboostTestData.ptr<float>(0),
xgboostTestData.channels()*sizeof (float));
//delete [] testDataPtr;
总结
以上就是今天要讲的内容,本文仅仅简单介绍了智能指针的使用
博主推荐: https://blog.csdn.net/bitcarmanlee/article/details/124847634