13.8 Write a smart pointer class. A smart pointer is a data type, usually implemented with templates, that simulates a pointer while also providing automatic garbage collection. It automatically counts the number of references to a SmartPointer<T*>…
Smart pointer line 58之后smart pointer里的计数已经是0,所以会真正释放它引用的对象,调用被引用对象的析构函数.如果继续用指针访问,会出现如下图的内存访问异常.所以说如果选择了用智能指针,就不要再试图用其他方式再去访问对象了. // sharedTest.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <boost/…