title: When using vectors does pop_back remove values along with elements?
body: <p>Why is this statement:</p>
  
  <pre><code>cout &lt;&lt; values[0] &lt;&lt; " " &lt;&lt; values[1] &lt;&lt; " " &lt;&lt; values[2] &lt;&lt; endl;
  </code></pre>
  
  <p>Showing </p>
  
  <blockquote>
    <p>1 2 3</p>
  </blockquote>
  
  <p>Even though pop back was used to remove the last element from the vector. Shouldn't the values be removed too? Or does the vector resize even though the element is removed?</p>
  
  <p>Here is the sample code:</p>
  
  <pre><code>// This program demonstrates the vector pop_back member function.
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main()
  {
      vector&lt;int&gt; values;
  
      // Store values in the vector.
      values.push_back(1); // Last element in values is 1
      values.push_back(2); // Now elements in values are 1,2
      values.push_back(3); // Now elements in values are 1,2,3
  
      cout &lt;&lt; "The size of values is " &lt;&lt; values.size() &lt;&lt; endl; // values has 3 elements
  
      // Remove a value from the vector.
      cout &lt;&lt; "Popping a value from the vector...\n";
      values.pop_back();
      cout &lt;&lt; "The size of values is now " &lt;&lt; values.size() &lt;&lt; endl; // 1 is Removed thus size is 2
      cout &lt;&lt; values[0] &lt;&lt; " " &lt;&lt; values[1] &lt;&lt; " " &lt;&lt; values[2] &lt;&lt; endl;
  
      // Now remove another value from the vector.
      cout &lt;&lt; "Popping a value from the vector...\n";
      values.pop_back();
      cout &lt;&lt; "The size of values is now " &lt;&lt; values.size() &lt;&lt; endl;
      cout &lt;&lt; values[0] &lt;&lt; " " &lt;&lt; values[1] &lt;&lt; " " &lt;&lt; values[2] &lt;&lt; endl;
  
  
      // Remove the last value from the vector.
      cout &lt;&lt; "Popping a value from the vector...\n";
      values.pop_back();
      cout &lt;&lt; "The size of values is now " &lt;&lt; values.size() &lt;&lt; endl;
      cout &lt;&lt; values[0] &lt;&lt; " " &lt;&lt; values[1] &lt;&lt; " " &lt;&lt; values[2] &lt;&lt; endl;
  
      return 0;
  
  }
  </code></pre>