I am having trouble understanding how to create a 2 dimentional vector (a vector of vectors) and have it act like I want it to.
Code:
void test2dVector(){
vector <vector <int> > v; //*two dimensions
v.push_back(vector <int>()); //*create v[0]
v.push_back(vector <int>()); //*create v[1]
v[0].push_back(15); //*assign v[0][0]
v[1].push_back(16); //*assign v[1][0]
for(size_t i=0;i<v.size();i++)
{
for (size_t j=0;j<v[i].size();j++)
{
cout<<v[i][j]<<" "; //I am not sure that this will work! Will it?
}
cout<<"\n";
}
}
In this code, I try to create and use a 2-d vector.
I still do not understand how to make it act like a real 2-d array, meaning, creating an actual grid-like structure, as opposed to this, which only covers one column.
So once and for all, can somebody FULLY explain how to do this, completely?