Advertisement
jtentor

DemoStack3 - Cpp - Main

May 9th, 2020
1,142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #include <iostream>
  6. #include <stack>
  7.  
  8. int main() {
  9.     std::cout << "Demo de Stack - Pila" << std::endl;
  10.  
  11.     std::stack<char> miPila = std::stack<char>();
  12.  
  13.     miPila.push('a');
  14.     miPila.push('b');
  15.     miPila.push('c');
  16.  
  17.     while (!miPila.empty()) {
  18.         std::cout << miPila.top() << std::endl;
  19.         miPila.pop();
  20.     }
  21.  
  22.     try {
  23.         miPila.pop();
  24.     }
  25.     catch (std::exception const & e) {
  26.         std::cout << e.what() << std::endl;
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
RAW Paste Data Copied
Advertisement