home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_01 / allison / tstack2.h < prev   
Encoding:
C/C++ Source or Header  |  1993-12-07  |  572 b   |  45 lines

  1. // tstack2.h
  2. #include <iostream.h>
  3. #include "stack2.h"
  4.  
  5. main()
  6. {
  7.     Stack<int> s1(5), s2(5);
  8.  
  9.     // Push odds onto s1, evens onto s2:
  10.     for (int i = 1; i < 10; i += 2)
  11.     {
  12.         s1.push(i);
  13.         s2.push(i+1);
  14.     }
  15.  
  16.     // Retrieve and print in LIFO order:
  17.     cout << "Stack 1:\n";
  18.     while (!s1.empty())
  19.         cout << s1.pop() << endl;
  20.  
  21.     cout << "Stack 2:\n";
  22.     while (!s2.empty())
  23.         cout << s2.pop() << endl;
  24.  
  25.     return 0;
  26. }
  27.  
  28. /* Output:
  29. Stack 1:
  30. 9
  31. 7
  32. 5
  33. 3
  34. 1
  35. Stack 2:
  36. 10
  37. 8
  38. 6
  39. 4
  40. 2
  41. */
  42.  
  43. /* End of File */
  44.  
  45.