代码
#include<iostream>
using namespace std;
#include<memory> // 头文件
class TestClass
{
private:
	int Value;
public:
	TestClass(int value) :Value(value) {
		cout << "构造函数调用" << endl;
	}
	~TestClass() {
		cout << "析构函数调用" << endl;
	}
	void hello()
	{
		cout << "hello, smart ptr!" << endl;
	}
};
int main()
{
	shared_ptr<TestClass> pTest(new TestClass(8));
	pTest->hello();
	return 0;
}
 
结果




















