Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 6th, 2013  |  syntax: C++  |  size: 0.44 KB  |  views: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "stack.hpp"
  2.  
  3. STACK::STACK()
  4. {
  5.   Head = NULL;
  6. }
  7.  
  8. STACK::~STACK()
  9. {
  10.   int value;
  11.  
  12.   while (!Is_Empty())
  13.   {
  14.     Pop(value);
  15.   }
  16. }
  17.  
  18. int STACK::Is_Empty()
  19. {
  20.   return Head == NULL;
  21. }
  22.  
  23. void STACK::Push(int value)
  24. {
  25.   NODE * temp = new NODE;
  26.   temp->value = value;
  27.   temp->link = Head;
  28.   Head = temp;
  29. }
  30.  
  31. void STACK::Pop(int &value)
  32. {
  33.   NODE * temp = Head;
  34.   value = Head->value;
  35.   Head = Head->link;
  36.   delete temp;
  37. }
clone this paste RAW Paste Data