I use this piece of code . works fine for me .copy it and run on your computer. you'll understand by yourself .
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <vector <int> > matrix;
size_t row=3 , col=3 ;
for(int i=0,cnt=1 ; i<row ; i++)
{
for(int j=0 ; j<col ; j++)
{
vector <int> colVector ;
matrix.push_back(colVector) ;
matrix.at(i).push_back(cnt++) ;
}
}
matrix.at(1).at(1) = 0; //matrix.at(columns).at(rows) = intValue
//printing all elements
for(int i=0,cnt=1 ; i<row ; i++)
{
for(int j=0 ; j<col ; j++)
{
cout<<matrix[i][j] <<" " ;
}
cout<<endl ;
}
}