1.智能指针
头文件:memory
#include<memory>
本质:一个类
shared_ptr(共享形智能指针)
#include<iostream>
#include<memory>
using namespace std;
int main()
{
shared_ptr<int> ps(new int(1));
}
get()函数-返回对象管理的内存的指针
#include<iostream>
#include<memory>
using namespace std;
int main()
{
shared_ptr<int> ps(new int(1));
int*p=ps.get();//返回指针(地址)
}
usr_count-返回管理数
#include<iostream>
#include<memory>
using namespace std;
int main()
{
shared_ptr<int> ps(new int(1));
int*p=ps.get();//返回指针(地址)
cout << ps.use_count() << endl;//返回管理数
}
swap()-交换管理对象
#include<iostream>
#include<memory>
using namespace std;
int ma