c++智能指针学习
来源:互联网 发布:大魔王女神淘宝 编辑:程序博客网 时间:2024/06/05 07:00
Demo1:
#include <iostream>#include <string>#include <memory>using std::cout;using std::string;class A{ public: int number; string info; A(int param=0) { number=param; cout<<"A() :"<<number<<"\n"; } ~A() { cout<<"~A() :"<<number<<"\n"; } void print() const { cout<<"print() "<<info.c_str()<<std::endl; }};void test();int main(){ test(); A(1); return 0;}void test(){ std::auto_ptr<A> _ptr(new A(1)); if(_ptr.get()) { _ptr->print(); _ptr.get()->info="Addition"; _ptr->print(); (*_ptr).info+="other"; _ptr->print(); }}测试结果
0 0
- C/C++学习笔记:智能指针详解
- C++primer学习笔记----智能指针
- 一起学习C,C++__boost--智能指针(3)
- c++:智能指针
- C++:智能指针
- 【C++】智能指针
- 【C++】智能指针
- C++PJ智能指针
- 【c++】智能指针
- 【C++】智能指针auto_ptr
- C++,智能指针
- C++,boost智能指针
- 智能指针模拟C
- [C++]智能指针
- 【C++】 浅析智能指针
- C++_智能指针
- C++:初识智能指针
- C++::智能指针
- JAVAWeb之JSP学习笔记一
- Light—oj 1045 - Digits of Factorial
- oracle 12c 创建表空间,用户并指定表空间,以及授权
- POJ 2762 Going from u to v or from v to u? 弱连通分量 -
- 使用NFC打开网页
- c++智能指针学习
- OpenGL应用开发----基础数学
- java环境变量设置
- Leetcode-345-Reverse Vowels of a String
- PilotEdit v9.7
- 三角形锥形(1)
- 带你读开源—ASP.NET_MVC(一)
- POJ 1556 The Doors (计算几何判断线段相交+最短路)
- 《UNIX环境高级编程》第5章标准IO中的内存流