Advertisement
Phr0zen_Penguin

ABStack.cpp - VTC C++ Array-Based Stack Example

Apr 29th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. /**
  2.  * [ABStack.cpp]
  3.  * Array-based stack example.
  4.  *
  5.  * compile with:
  6.  * g++ -m32 -static-libgcc -o abstack ABStack.cpp ArrayBasedStack.cpp
  7.  */
  8.  
  9. #include "ArrayBasedStack.h"
  10.  
  11. int main(void)
  12. {
  13.     /**
  14.      * Array-Based Stack OBJECT CREATION:
  15.      */
  16.     ArrayBasedStack *ABStack = new ArrayBasedStack();   // a stack created on the heap :|
  17.  
  18.  
  19.     /**
  20.      * Array-Based Stack ITEM ADDITION:
  21.      */
  22.         if(!ABStack->IsFull()) ABStack->Push(2.4);
  23.         if(!ABStack->IsFull()) ABStack->Push(1.3);
  24.  
  25.  
  26.     /**
  27.      * Array-Based Stack ITEM RETRIEVAL:
  28.      */
  29.     float   newItem;
  30.  
  31.         while(!ABStack->IsEmpty())
  32.         {
  33.             ABStack->Pop(newItem);
  34.  
  35.             std::cout << newItem << std::endl;
  36.         }
  37.  
  38.  
  39.     /**
  40.      * Array-Based Stack OBJECT DELETION:
  41.      */
  42.     delete ABStack;
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement