求大神看下return后变量不是离开作用域了吗,怎么还有效呢?
#include <iostream>
#include <vector>
#include <memory>
using namespace std;
shared_ptr<vector<int> > new_vector()
{
return make_shared<vector<int>>();
}
int main()
{
shared_ptr<vector<int>> pv = new_vector(); //这里返回的有效吗?
if (!pv){
cout << "not enough memory " << endl;
}
return 0;
}