Demonstrating the STL vector back and pop_back operations : vector back « Vector « C++






Demonstrating the STL vector back and pop_back operations

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

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

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

  while (vector1.size() > 0) {
    cout << vector1.back();
    vector1.pop_back();
  }
  cout << endl;
  return 0;
}

/* 
jihgfedcba

 */        
  








Related examples in the same category

1.Get the last element in the vector