programming-examples/c++/Others/A simple stack example push, empty, pop and top.cpp

23 lines
410 B
C++
Raw Normal View History

2019-11-15 12:59:38 +01:00
A simple stack example: push, empty, pop and top
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<char> stackObject;
stackObject.push('A');
stackObject.push('B');
stackObject.push('C');
stackObject.push('D');
while(!stackObject.empty()) {
cout << "Popping: ";
cout << stackObject.top() << endl;
stackObject.pop();
}
return 0;
}