title: Last object in a vector disappearing after applying erase() for the first time
body: <p>I have a very weird problem and I apologize in advance if what I am about to say sounds silly.</p>
  
  <p>I am developing a simple 3D game, and I am using c++, OpenGL 4.1, and Xcode 9.2 on MacBook Pro. I am a beginner, and I am struggling with vectors of objects. In particular, I managed to create several instances of a given object and display all of them in my scene. I am now trying to handle the deletion of one object at a time, say the first for simplicity. Therefore, I simply apply the erase() function to the vector, but, even though only the first element in the vector is actually erased, the last one also disappears from the scene.
  I checked that the iterator was scanning the updated list correctly (although there was no need since the deletion is outside the for loop). I also paused the program and looked into the memory to see if the last object was still present, and it was. I thought the last object was simply overlapping another one, but was not because its model transformation matrix was different from the others.
  As a last test (I am desperate now), I have written a portion of code that re-push_back()s all the elements when none is left after repeatedly use erase(). The problem persists.
  What could I be doing wrong?
  Here is part of the code (imagine that the vector "blocks" has already 6 elements in the beginning):</p>
  
  <pre><code>if (fire){ // mouse button pressed
      fire = false;
      num_of_blocks--;
      blocks.erase(blocks.begin()); //delete first element, but last disappears!!
      if (num_of_blocks==0){
          first = true;
          num_of_blocks = 6;
      }
  
  }
  if (first){
      first = false;
      Vector3f pos = Vector3f(0,1,-3);
      for (int i=0; i&lt;num_of_blocks;i++){
          pos.z() -= 2;
          Parallelepiped newBlock = Parallelepiped(_textureWall.GetID(),2.0f,0.5f,1.2f);
          blocks.push_back(newBlock);
          blocks[i].setPosition(pos);
      }
  }
      for (vector&lt;Parallelepiped&gt;::iterator it = blocks.begin(); it !=blocks.end(); it++){
      drawObject(&amp;shaders[0], &amp;(*it));
  }
  </code></pre>
  
  <p>Thank you in advance. </p>