87

智能指针的原理及其应用-Dream

 6 years ago
source link: http://blog.51cto.com/12951882/2088711
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
所谓智能指针就是自动化管理指针所指向的动态资源的释放。那么智能指针的引用是为了解决哪些问题呢?代码中经常会忘掉释放动态开辟的资源,引用智能指针可用于动态资源管理,资源分配即初始化,定义一个类来封装资源的分配和释放,在构造函数中完成资源的分配和初始化,在析构函数完成资源的清理,可以保证资源的正确初始化和释放。智能指针的原理:智能指针是一个类,这个类的构造函数中传入一个普通指针,析构函数中释放传入的指

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK