smart pointer
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 <class T> 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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步