SHARE
TWEET

Untitled

a guest Apr 6th, 2013 18 Never
  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. }
RAW Paste Data
Top