title: Using an iterator to print out every member of a set
body: <p>I'm trying to use an iterator to print out every member of a set. As far as I can tell from other stackoverflow answers, I have the correct formatting. When I run this code, it correctly outputs that the size of myset is 3, but it only outputs ii once. If I uncomment the line with *iter, Visual Studio throws a runtime exception saying that that "map/set iterator is not dereferencable. Any idea why?</p>
  
  <pre><code>int main()
  {
  set&lt;int&gt; myset;
  myset.insert(5);
  myset.insert(6);
  myset.insert(7);
  set&lt;int&gt;::iterator iter;
  cout&lt;&lt;myset.size()&lt;&lt;endl;
  int ii=0;
  for(iter=myset.begin(); iter!=myset.end();++iter);{
      //cout&lt;&lt;(*iter)&lt;&lt;endl;
      ii+=1;
      cout&lt;&lt;ii&lt;&lt;endl;
  }
  return 0;
  }
  </code></pre>