- Learning C++ Functional Programming
- Wisnu Anggoro
- 127字
- 2021-07-02 20:51:38
Avoiding manual memory management with smart pointers
The smart pointers are highly useful and have an essential knowledge in using C++ efficiently. C++11 added many new abilities for the smart pointer we can find in the memory header file. For a long time, before C++11, we used auto_ptr as a smart pointer. However, it was quite unsafe since it had incompatible copy semantics. It's also deprecated now, and we should not use it anymore. Fortunately, C++ has presented unique_ptr, which has a similar functionality, but with additional features, such as adding deleters and support for arrays. Anything we can do with auto_pt, we can and should do with unique_ptr instead. We will discuss unique_ptr in depth along with other new smart pointers in C++11--shared_ptr and weak_ptr.
推薦閱讀
- 極簡算法史:從數學到機器的故事
- Learning Real-time Processing with Spark Streaming
- Learning Apex Programming
- 認識編程:以Python語言講透編程的本質
- HTML5 and CSS3 Transition,Transformation,and Animation
- Unity Shader入門精要
- 組態軟件技術與應用
- Julia高性能科學計算(第2版)
- Lighttpd源碼分析
- Go語言精進之路:從新手到高手的編程思想、方法和技巧(2)
- 基于SpringBoot實現:Java分布式中間件開發入門與實戰
- Mastering VMware Horizon 7(Second Edition)
- Java設計模式深入研究
- Getting Started with the Lazarus IDE
- JavaScript程序設計實例教程(第2版)