Advertisement
Phr0zen_Penguin

ArrayBasedStack.cpp - VTC C++ Array-Based Stack

Apr 29th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. /**
  2.  * [ArrayBasedStack.cpp]
  3.  * The ArrayBasedStack class definition/implementation.
  4.  */
  5.  
  6. #include "ArrayBasedStack.h"
  7.  
  8. /**
  9.  * ArrayBasedStack CLASS CONSTRUCTOR(s):
  10.  */
  11. ArrayBasedStack::ArrayBasedStack()
  12. {
  13.     top = -1;
  14. }
  15.  
  16.  
  17. /**
  18.  * ArrayBasedStack CLASS ACCESSORS:
  19.  */
  20. void ArrayBasedStack::Pop(float &item)
  21. {
  22.     item = data[top];
  23.     top--;
  24. }
  25.  
  26.  
  27. /**
  28.  * ArrayBasedStack CLASS MUTATORS:
  29.  */
  30. void ArrayBasedStack::Push(float item)
  31. {
  32.     top++;
  33.     data[top] = item;
  34. }
  35.  
  36.  
  37. /**
  38.  * ArrayBasedStack CLASS GENERAL USE FUNCTIONS:
  39.  */
  40. void ArrayBasedStack::MakeEmpty(void)
  41. {
  42.     top = -1;
  43. }
  44.  
  45. bool ArrayBasedStack::IsEmpty(void)
  46. {
  47.     return (top == -1);
  48. }
  49.  
  50. bool ArrayBasedStack::IsFull(void)
  51. {
  52.     return (top == MAX_LENGTH);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement