1. 介绍 在 C++ 中没有垃圾回收机制,必须自己释放分配的内存,否则就会造成内存泄露.解决这个问题最有效的方法是使用智能指针(smart pointer).智能指针是存储指向动态分配(堆)对象指针的类,用于生存期的控制,能够确保在离开指针所在作用域时,自动地销毁动态分配的对象,防止内存泄露.智能指针的核心实现技术是引用计数,每使用它一次,内部引用计数加1,每析构一次内部的引用计数减1,减为0时,删除所指向的堆内存. C++11 中提供了三种智能指针,使用这些智能指针时需要引用头文件 : st
Then what's really happening is TWO different sections of memory are being allocated. It's done at one time, but it's two "logical" blocks. One is the int which stores the actual value, and the other is the control block, which stores all the