title: Segmentation fault when erasing last element in vector
body: <p>I'm trying to erase the last element in the vector using iterator. But I'm getting segmentation fault when erasing the element.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>    for (vector&lt;AccDetails&gt;::iterator itr = accDetails.begin(); itr != accDetails.end(); ++itr) {
      if (username == itr-&gt;username) {
              itr = accDetails.erase(itr);
      }
  }
  </code></pre>
  
  <p>Is there something wrong with my iteration?</p>