title: Iterators in C++ (stl) vs Java, is there a conceptual difference?
body: <p>I'm returning to c++ after being away for a bit and trying to dust off the old melon. </p>
  
  <p>In Java Iterator is an interface to a container having methods: <code>hasNext()</code>, <code>next()</code> and <code>remove()</code>. The presence of <code>hasNext()</code> means it <strong>has the concept of a limit</strong> for the container being traversed.</p>
  
  <pre><code>//with an Iterator
  Iterator&lt;String&gt; iter = trees.iterator();
  while (iter.hasNext()) 
  {
      System.out.println(iter.next());
  }
  </code></pre>
  
  <p>In the C++ standard template library, iterators seem to represent a datatype or class the supports the <code>operator++</code> and <code>operator==</code> but has <strong>no concept of a limit</strong> built in so comparison is required before advancing to the next item. The limit has to checked by the user comparing two iterators in the normal case the second iterator is the container end.</p>
  
  <pre><code>vector&lt;int&gt; vec;
  vector&lt;int&gt;::iterator iter;
  
  // Add some elements to vector
  v.push_back(1);
  v.push_back(4);
  v.push_back(8);
  
  for (iter= v.begin(); iter != v.end(); iter++)
  {
      cout &lt;&lt; *i &lt;&lt; " "; //Should output 1 4 8
  }
  </code></pre>
  
  <p>The interesting part here is that in C++ a pointer is an iterator to an array. The STL took what was existing and build convention around it.</p>
  
  <p>It there any further subtlety to this that I am missing?</p>