title: strange output when using with vector iterato
body: <p>I am getting strange output when running following code. 
  In the getMeanGap function given below, it prints different vector element when comparing with vector elements printed in the calling function</p>
  
  <pre><code>//===Main Function========
  
      cout &lt;&lt; "&gt;&gt;" &lt;&lt; endl;
      for (typename vector&lt;Type&gt;::iterator it = v1.begin(); it != v1.end(); ++it)
      {
        cout &lt;&lt; it-&gt;x &lt;&lt; "\t" &lt;&lt; it-&gt;y &lt;&lt; endl; // "\t" &lt;&lt; it-&gt;width &lt;&lt; "\t" &lt;&lt; it-&gt;height &lt;&lt; endl;
      }
  
      cout &lt;&lt; getMeanGap(v1) &lt;&lt; endl;
  
  //=======================
  </code></pre>
  
  <p>the getMeanGap function given below</p>
  
  <pre><code>template&lt;typename Type&gt;
  float VIDSegment::getMeanGap(const vector&lt;Type&gt; &amp; vec) const
  {
    if (vec.size() &lt; 2) return 0.0;
    cout &lt;&lt; "----" &lt;&lt;endl;
    float sum = 0.0;
    for (typename vector&lt;Type&gt;::const_iterator it = vec.begin() - 1; it != vec.end(); ++it)
    {
      typename vector&lt;Type&gt;::const_iterator temp = it;
      temp++;
      cout &lt;&lt; it-&gt;x &lt;&lt; "\t" &lt;&lt; it-&gt;y &lt;&lt; endl;
      sum += ( (temp-&gt;x) - (it-&gt;x) - (it-&gt;width));
    }
    return float(sum / (vec.size() - 1));
  }
  </code></pre>
  
  <p>While running above code I am getting following result</p>
  
  <pre><code>&gt;&gt;
  26  51
  56  19
  112 23
  175 25
  211 26
  331 23
  379 23
  424 23
  471 23
  ----
  0 0    // ??
  26  51
  56  19
  112 23
  175 25
  211 26
  331 23
  379 23
  424 23
  471 23
  </code></pre>
  
  <p>May I know the reason for the above output ??</p>