64,687
社区成员
发帖
与我相关
我的任务
分享
#include "StdAfx.h"
#include "memory"
#include "string"
#include <iostream>
using namespace std;
int main()
{
auto_ptr<string> p1(new string("I'm p1"));
auto_ptr<string> p2(p1);
cout<<*p1<<":"<<(&p1)<<endl;
cout<<*p2<<":"<<(&p2)<<endl;
if (p1.get())
cout<<"p1 is full"<<endl;
if (p2.get())
cout<<"p2 is full"<<endl;
}
#include "StdAfx.h"
#include "memory"
#include "string"
#include <iostream>
using namespace std;
void f(auto_ptr<string> p)
{
cout<<"f: "<<*p<<endl;
}
int main()
{
auto_ptr<string> p1(new string("I'm p1"));
f(p1);
cout<<*p1<<":"<<(&p1)<<endl;
if (p1.get())
cout<<"p1 is full"<<endl;
}
#include "StdAfx.h"
#include "memory"
#include "string"
#include <iostream>
using namespace std;
void f(auto_ptr<string> p)
{
cout<<"f: "<<*p<<endl;
}
int main()
{
auto_ptr<string> p1(new string("I'm p1"));
auto_ptr<string> p2(p1);
f(p1);
cout<<*p1<<":"<<(&p1)<<endl;
cout<<*p2<<":"<<(&p2)<<endl;
if (p1.get())
cout<<"p1 is full"<<endl;
if (p2.get())
cout<<"p2 is full"<<endl;
}