title: Problems using 3-dimensional vector
body: <p>How can I work with a 3 dimensional vector in C++?</p>
  
  <pre><code>vector&lt;vector&lt;vector&lt;int&gt; &gt; &gt; vec (1,vector&lt;vector&lt;int&gt; &gt;(1,vector &lt;int&gt;(1,12)));
  </code></pre>
  
  <p>When I try something like this</p>
  
  <pre><code>cout &lt;&lt; vec[0][0][0]; vec[0][0][1] = 13;
  </code></pre>
  
  <p>everything works just fine.</p>
  
  <p>The problem is that I can only change the last elements. If I try accessing the first and second element, like this</p>
  
  <pre><code>vec[0][1][0] = 13;
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>vec.push_back(vector&lt;vector&lt;int &gt; &gt;());
  vec[0].push_back(vector&lt;int&gt;()); 
  v[1][0].push_back(13);
  </code></pre>
  
  <p>my program crashes.</p>
  
  <p>How can I add and access elements in a 3d vector?</p>