Iterators and multi-dimensional vectors?
<p>So, I am trying to build a two-dimensional vector that will hold indexes for selecting tiles from a tileset.</p>

<p>An iterator in one dimension is simple enough:</p>

<pre><code>std::vector&lt;int&gt; vec;
std::vector&lt;int&gt;::iterator vec_it;

for(int i=5; i&gt;0; --i){
  vec.push_back(i);   }

//prints "5 4 3 2 1 "
for(vec_it = vec.begin(); vec_it != vec.end(); ++vec_it){
  std::cout&lt;&lt;*vec_it&lt;&lt;' ';
}
</code></pre>

<p>However, I'm running into trouble when adding the second dimension. Here's the code that <b>doesn't</b> work:</p>

<pre><code>std::vector&lt;std::vector&lt;int&gt; &gt; vec(5);
std::vector&lt;std::vector&lt;int&gt; &gt;::iterator vec_it;
std::vector&lt;int&gt;::iterator inner_it;

for(int i=0; i&lt;5; ++i){
  vec[i].assign(5, 0);
}

for(vec_it = vec.begin(); vec_it != vec.end(); ++vec_it){
  for(inner_it = *vec_it-&gt;begin(); inner_it != *vec_it-&gt;end(); ++inner_it){
    std::cout&lt;&lt;*inner_it&lt;&lt;' ';
  }
  std::cout&lt;&lt;std::endl;
}

//should print:
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
//0 0 0 0 0
</code></pre>

<p>The compile fails with a nearly-incomprehensible error where I try to do <code>inner_it = *vec_it-&gt;begin()</code>, so I suppose my question is, how badly did I screw up?</p>
