shared_ ptr 是一个引用计数智能指针,用于共享对象的所有权也就是说它允许多个指针指向同一个对象。
Demo
#include<iostream>
#include<memory>
using namespace std;
class 0bject
{
private:
int value;
public:
0bject(int x = 0) :value(x)
{
cout << "Constructor object..." << endl;
}
~0bject() {
cout << "Destructor 0bject..." << endl; }
int& Value() {
return value; }
const int