Demonstrating the STL vector front and erase operations. : vector front « vector « C++ Tutorial






#include <iostream>
#include <vector>
#include <string>
using namespace std;


int main()
{
  string s("abcdefghij");

  vector<char> vector1(s.begin(), s.end());

  cout << "Popping characters off the front produces: ";

  while (vector1.size() > 0) {
    cout << vector1.front();
    vector1.erase(vector1.begin());
  }
  cout << endl;
  return 0;
}
Popping characters off the front produces: abcdefghij








16.16.vector front
16.16.1.Get the first element in a vector
16.16.2.Demonstrating the STL vector front and erase operations.