boost::smart_ptr之智能指针
来源:互联网 发布:淘宝做什么产品赚钱 编辑:程序博客网 时间:2024/06/05 05:28
前言:
1.scoped_ptr 智能指针使用说明
示例代码:
#include "stdafx.h"#include <boost/smart_ptr.hpp>#include <iostream>using namespace std;using namespace boost;class posix_file{public:posix_file(const char * file_name){cout << "open file! " << *file_name << endl; }~posix_file(){cout << "close file!" << endl;}};int main(int argc, _TCHAR* argv[]){/************************************************************************//*scoped_ptr不允许赋值,拷贝,不支持--和++,只能在被声明的作用域内使用 *//************************************************************************/scoped_ptr<string> sptr(new string("test"));cout << "指针内容为:" << (*sptr).c_str() << endl;cout << "指针内容长度为:" << sptr->size() << endl;scoped_ptr<int> iptr (new int);*iptr = 1000;cout << *iptr << endl;{scoped_ptr<posix_file> fptr(new posix_file("/file/filename"));}while (1);return 0;}运行结果:
0 0
- boost::smart_ptr之智能指针
- <Boost> smart_ptr智能指针
- Boost.smart_ptr智能指针
- boost.Smart_ptr中智能指针
- boost.smart_ptr-智能指针scoped_ptr
- boost.smart_ptr-智能指针scoped_array
- boost.smart_ptr-智能指针scoped_array
- boost.smart_ptr-智能指针scoped_ptr
- boost.smart_ptr-智能指针scoped_ptr
- boost.smart_ptr-智能指针scoped_ptr
- 【02】 Boost库学习笔记之智能指针(Smart_ptr)
- 智能指针Boost.smart_ptr学习2--scoped_ptr
- 智能指针Boost.smart_ptr学习3--scoped_array
- 智能指针Boost.smart_ptr学习4--shared_ptr
- 智能指针Boost.smart_ptr学习5--shared_array
- 智能指针Boost.smart_ptr学习6--intrusive_ptr
- 智能指针Boost.smart_ptr学习1--为什么使用智能指针
- Boost之Smart_ptr库
- 警校妹子的别样青春
- Spark1.6.0 源码编译和部署包生成
- C程序中的段错误跟踪
- 把自己的功能某块,嵌入到其他PHP项目当中
- c++ 文件及文件夹操作(三)
- boost::smart_ptr之智能指针
- Web开发基础Tomcat的配置以及http协议概述
- 【LeetCode】066.Plus One
- iOS之一路问题
- Lucene实践:全文检索的基本原理
- 转载好文章【当推荐算法开源包多如牛毛,为什么我们还要专门的推荐算法工程师】
- 怎样在Ubuntun12.04上编译GCC
- iOS开发UI篇—自定义瀑布流控件(接口设计)
- C++中Lambda表达式