Mega Code Archive

 
Categories / C++ Tutorial / Queue Stack
 

A stack for characters

#include <iostream> #include <string> #include <queue> #include <stack> using namespace std; int main() {   stack<char> stck;   cout << "A stack for characters.\n";   cout << "Pushing A, B, C, and D.\n";   stck.push('A');   stck.push('B');   stck.push('C');   stck.push('D');   cout << "Now, retrieve those values in LIFO order.\n";   while(!stck.empty()) {     cout << "Popping: ";     cout << stck.top() << "\n";     stck.pop();   }   return 0; }