标签:name c++ using oid only ring cout bit HERE
#include<bits/stdc++.h>
using namespace std;
void swap(shared_ptr<int>a,shared_ptr<int>b)
{
int t;
t=*a,*a=*b,*b=t;
}
int main()
{
/*auto_ptr; unique_ptr; shared_ptr;
auto_ptr<int> p;
auto_ptr<int> p2(p);
auto_ptr<int> p3(new int(10));*/
auto_ptr<string> p1(new string("there is only one point to me."));
auto_ptr<string> p2;
cout<<*p1<<endl;
p2=p1;
//cout<<*p1<<endl;
cout<<*p2<<endl;
auto_ptr<string> p3(p2);
//cout<<*p2<<endl;
cout<<*p3<<endl;
unique_ptr<string> pl1(new string("auto"));
unique_ptr<string> pl2;
//unique_ptr<string> p3(p1);
//p2=p1
shared_ptr<int> p11(new int(9));shared_ptr<int> p22(p11);
shared_ptr<int> p33(new(int)),p44(new int(8)),p55;
cout<<*p11<<" "<<*p44<<endl; swap(p11,p44); cout<<*p11<<" "<<*p44<<endl;
//cout<<*p11<<" "<<*p22<<" "<<*p33<<" "<<*p44<<" "<<*p55<<endl;
}
标签:name c++ using oid only ring cout bit HERE
原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/8910004.html