Advertisement
Phr0zen_Penguin

GenStack.cpp - VTC C++ Template Example

May 3rd, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. /**
  2.  * [GenStack.cpp]
  3.  * Templates part 2.
  4.  *
  5.  * compile with:
  6.  * g++ -m32 -static-libgcc -o genstack GenStack.cpp
  7.  */
  8.  
  9. #include "GenStack.h"
  10.  
  11. int main(void)
  12. {
  13.     /**
  14.      * GENERIC STACK OBJECT CREATION:
  15.      */
  16.     GenStack<float>         *fStack = new GenStack<float>();
  17.  
  18.     /**
  19.      * GENERIC STACK ITEM PUSH:
  20.      */
  21.     fStack->Push(2.4);
  22.  
  23.  
  24.     /**
  25.      * GENERIC STACK OBJECT CREATION:
  26.      */
  27.     GenStack<std::string>   *sStack = new GenStack<std::string>();
  28.  
  29.     /**
  30.      * GENERIC STACK ITEM PUSH:
  31.      */
  32.     sStack->Push("Hello free world!");
  33.  
  34.     /**
  35.      * GENERIC STACK ITEM POP/DISPLAY:
  36.      */
  37.     std::cout << sStack->Pop() << "  You are " << fStack->Pop() << "." << std::endl;
  38.  
  39.  
  40.     /**
  41.      * GENERIC STACK OBJECT DELETION:
  42.      */
  43.     delete fStack;
  44.     delete sStack;
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement