title: Erasing a class element from the vector C++
body: <p>I've faced a problem when I've tried to erase an element from the vector. Vector is filled with Class elements (class is called Node). So I've tried this:</p>
  
  <pre><code>int index = 2;
  vector&lt;Node&gt; openNodesSet;
  openNodesSet.erase(index);
  </code></pre>
  
  <p>But this is not working. I've found a solution:</p>
  
  <pre><code>int index = 2;
  vector&lt;Node&gt; openNodesSet;
  vector&lt;Node&gt;::iterator it = openNodesSet.begin();
  advance(it, lowestIndex);
  openNodesSet.erase(it);
  </code></pre>
  
  <p>Could somebody explane me why the first way is not working and the second one works without any problem? Is there any other ways to remove an element from the vector?</p>