```vector<shared_ptr<int>> v; 怎么循环往里放值呢,有代码可以参考下吗?往模板里放智能指针类型
v.push_back(ptr)
不管是什么类型的变量,添加元素都是push_back
int b = c = 25;
shared_ptr<int> pa = make_shared<int>(25);
shared_ptr<int> pb = make_shared<int>(b);
shared_ptr<int> pc = shared_ptr<int>(pb);
v.push_back(pa);
v.push_back(pb);
v.push_back(pc);
v.push_back(make_shared<int>(25));
最好有完整的代码
就你的代码来说,可以用 make_shared
shared_ptr<vector<int>> pv = make_shared<vector<int>>();
int i , x;
for(i = 0; i < n; i++)
{
cin>>x;
(*pv).push_back(x);
}