list10-1.cpp
来自「这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明」· C++ 代码 · 共 28 行
CPP
28 行
#include <memory>
#include <iostream>
#include <string>
using namespace std;
void main(void)
{
string *Str1 = new string("hello");
string *Str2 = new string("out there");
auto_ptr<string> AutoPtr1(Str1);
auto_ptr<string> AutoPtr2(Str2);
cout << "auto ptr 1 has object " << *AutoPtr1 << endl;
cout << "auto ptr 1 pointer is " << AutoPtr1.get() << endl;
cout << "auto ptr 2 has object " << *AutoPtr2 << endl;
cout << "auto ptr 2 pointer is " << AutoPtr2.get() << endl;
AutoPtr1 = AutoPtr2;
cout <<"after assignment" << endl;
cout << "auto ptr 1 has object " << *AutoPtr1 << endl;
cout << "auto ptr 1 pointer is " << AutoPtr1.get() << endl;
cout << "auto ptr 2 has object " << *AutoPtr2 << endl;
cout << "auto ptr 2 pointer is " << AutoPtr2.get() << endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?