你是错误使用shared_ptr
shared_ptr是包装处于指向堆上的数据的指针的。
而不能用栈上的变量的地址,来初始化他。因为shared_ptr要负责这个变量的生死,函数结束后那个变量就自动没了,
而且shared_ptr 没有合适构造函数来接受指针。因此你用错了。
类似代码
----=====
int n=10;
shared_ptr<int> p = &n//错误
=============
int* n= new int;
shared_ptr<int> p=n;//错误
=======
int * n = new int ;
shared_ptr<int> p(n);//正确。