Stack of string and vector: push(), pop(), empty(), top() : stack « Queue Stack « C++






Stack of string and vector: push(), pop(), empty(), top()

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

int main()
{
     stack< string, vector<string> > s;

     s.push( "me" );

     s.push( "to" );
     s.push( "talk" );
     while ( !s.empty() ) {
          cout << s.top() << " ";
          s.pop();
     }
     return 0;
}
  
    
  








Related examples in the same category

1.Push and pop an int stack
2.Push and pop a vector stack
3.Push and pop a stack of list
4.Stack: size, pop and push
5.Stack: size and push
6.Stack: top, empty
7.Modify the top element in a stack
8.Pass stack to a function