#include <iostream>
#include <memory>//
using namespace std;
int main()
{
auto_ptr<string> ps(new string("jjhou"));
cout<< *ps <<endl;
cout<< ps->size() <<endl;
cout << "Hello World!" << endl;
return 0;
}
本文介绍了一段使用C++智能指针auto_ptr的代码示例,包括如何初始化、使用和释放资源。重点突出了auto_ptr在资源管理方面的特性。
#include <iostream>
#include <memory>//
using namespace std;
int main()
{
auto_ptr<string> ps(new string("jjhou"));
cout<< *ps <<endl;
cout<< ps->size() <<endl;
cout << "Hello World!" << endl;
return 0;
}
600
813
542
3251

被折叠的 条评论
为什么被折叠?
