Phr0zen_Penguin

LStack.cpp - VTC C++ Linked Stack Example

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