2D vector?

Can you show me how to use 2D vector, instead of 2D arrays?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>
vector<vector<int> > 2dVector;//2d vector
vector<int> 1dVector;//normal vector to fill the 2d vector
int width=10;//vector width
int height=10;//and height

for (int i=0; i<width; i++)
{
     1dVector.push_back(i);
}
for (int i=0; i<height; i++)
{
     2dVector.push_back(filler+i);
}
cout << 2dVector[2][2];//echo the vector at pos 2,2 

You can use it like this.
Not tested.
Topic archived. No new replies allowed.