#include<bits/stdc++.h>
using namespace std;
main()
{
vector<vector<int> > v;
for(int i = 0;i < 3;i++)
{
vector<int> temp;
for(int j = 0;j < 3;j++)
{
temp.push_back(j);
}
//cout<<typeid(temp).name()<<endl;
v[i].push_back(temp);
}
}
我试图给一个二维向量赋值。但是我遇到了以下错误:
No matching function for call to
std ::vector<int>::push_back(std::vector<int> &)
v.push_back(...)
translates to "Add an element to the end of a vector.") - Some programmer dudev[i]
访问越界。向量中没有条目。 - M.Mv.push_back(vector)
andv[i].push_back(int)
- Retired Ninja