title: Jumps out from For loop c++
body: <p>I have a little program that will simulate a jukebox. 
  I have a class for all songs, and a class for all albums that contain the Song classes. </p>
  
  <p>In this function I will print out all songs in the Album vector and use the iterator to give every song a number. 1.2.3.4.etc</p>
  
  <p>When I declare "int i" in the second for loop, then ofcourse after every album the int "i" will become 0 again. But when I declare it before all For loops, I only get the first album printed.</p>
  
  <p>How come?</p>
  
  <pre><code> void Jukebox::createList() {
      int i = 0;
  
      for (auto idx : albvec)
      {
  
          // Write out the songs
          for (i; i &lt; idx.getNrSongs(); i++)
          {
              cout &lt;&lt; i+1 &lt;&lt; "  " &lt;&lt; idx.getSongvec()[i].getArtist() &lt;&lt; " - ";
              cout &lt;&lt; idx.getSongvec()[i].getTitle() &lt;&lt; " ";
              Time t = idx.getSongvec()[i].getDuration();
              printTime(t);
              cout &lt;&lt; endl;
          }
      }
  
  }
  </code></pre>