博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
smart pointer
阅读量:4616 次
发布时间:2019-06-09

本文共 755 字,大约阅读时间需要 2 分钟。

A smart pointer is an abstract data type that stimulates a pointer with additional funationality, such as auto memory deallocation, reference counting, etc. In practise it could be a wrapper around of a regular pointer and forwards all meaningfull operations to the pointer

The simplest smart pointer is autr_ptr which are defined in header file <memory>

 

template 
auto_ptr {public: explicit auto_ptr(T* p): auto_ptr(p){} ~auto_prt() {delete ptr;} T& operator*(){
return *ptr;} T* operator->(){
return &ptr;}private: T* ptr; // other functionalities...};

 

 

 

 

reference:

- http://en.wikipedia.org/wiki/Smart_pointer

- http://ootips.org/yonat/4dev/smart-pointers.html

转载于:https://www.cnblogs.com/xispace/p/3375760.html

你可能感兴趣的文章
python协程函数、递归、匿名函数与内置函数使用、模块与包
查看>>
[ConcurrencyCheck]并发检查
查看>>
发布功能完成
查看>>
excel 合并单元格
查看>>
ASP.NET Core 使用 URL Rewrite 中间件实现 HTTP 重定向到 HTTPS
查看>>
Ubuntu Server无法安装busybox-initramfs
查看>>
List
查看>>
iOS设计模式简介
查看>>
HTML
查看>>
c# 扩展方法 奇思妙用 高级篇 九:OrderBy(string propertyName, bool desc)
查看>>
Log4net入门(ASP.NET MVC 5篇)
查看>>
C语言中的地址传递(传指针,传递给形参的指针仍然是实参指针的一份拷贝)
查看>>
redis缓存数据库及Python操作redis
查看>>
opencms忘记Admin用户登录密码解决方案
查看>>
forms组件
查看>>
C# 线程更新ui
查看>>
iOS 页面间几种传值方式(属性,代理,block,单例,通知)
查看>>
create-react-app 配置sass
查看>>
02_关系数据库
查看>>
Android和H5交互-基础篇
查看>>