Creating a matrix using STL vector
<p>I want to create a matrix using "vector":</p>

<pre><code>vector &lt; vector &lt;int&gt; &gt; Mat;
</code></pre>

<p>The problem is, when I run this code:</p>

<pre><code>int i ,j;
    for(i = 1  ; i &lt;= 5 ; ++i)
    for(j = 1 ; j &lt;= 5 ; ++j)
        Mat[i][j] = 0;
</code></pre>

<p>I would get a pretty nasty error. How can I fix that?</p>

<p>I do NOT want to read the matrix like this:</p>

<pre><code>for(i = 1  ; i &lt;= 5 ; ++i)
    for(j = 1 ; j &lt;= 5 ; ++j)
        M[i].push_back(0);
</code></pre>