您当前的位置: 首页 >  ar
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C++ 智能指针 shared_ptr、make_shared用法

软件工程小施同学 发布时间:2022-10-05 20:02:52 ,浏览量:0

一、使用shared_ptr条件

  1.  C++版本11以上

  2. 需引入头文件

#include 

否则编译会报错

error: ‘shared_ptr’ was not declared in this scope

二、用法

 

#include 
#include 
#include 
using namespace std;

class testClass
{
	public: 
		testClass(){
			temp3 = make_shared();
		}
		shared_ptr temp3;
};

int main() {

	cout            
关注
打赏
1665320866
查看更多评论
0.0419s