C++ Program to Illustrate Usage of Stack Adaptor
#include <iostream>
#include <stack>
int main()
{
std::stack< char > s;
// Pushing elements into stack
for (char c = 'a'; c <= 'f'; c++)
{
s.push(c);
}
while (!s.empty())
{
std::cout << "Top element of stack \'" << s.top()
<< "\'" << std::endl;
s.pop();
}
std::cout << "Stack is empty!" << std::endl;
}
Output:
Top element of stack 'f'
Top element of stack 'e'
Top element of stack 'd'
Top element of stack 'c'
Top element of stack 'b'
Top element of stack 'a'
Stack is empty!
