Mega Code Archive

 
Categories / C++ Tutorial / Vector
 

Demonstrating the STL vector front and erase operations

#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