Advertisement
Phr0zen_Penguin

ArrayBasedStack.h - VTC C++ Array-Based Stack Header

Apr 29th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. /**
  2.  * [ArrayBasedStack.h]
  3.  * The ArrayBasedStack class declaration/specification.
  4.  */
  5.  
  6. #ifndef ARRAYBASEDSTACK_H
  7. #define ARRAYBASEDSTACK_H
  8.  
  9. #include <iostream>
  10.  
  11. const   int MAX_LENGTH = 500;   // the maximum size of the stack
  12.  
  13. class ArrayBasedStack
  14. {
  15.     /**
  16.      * Everything under public can be accessed by all other programs or classes.
  17.      */
  18.     public:
  19.         /**
  20.          * Constructor(s):
  21.          */
  22.         ArrayBasedStack();
  23.  
  24.         /**
  25.          * Mutators:
  26.          */
  27.         void Push(float);
  28.  
  29.         /**
  30.          * Accessors:
  31.          */
  32.         void Pop(float &);
  33.  
  34.         /**
  35.          * General Use:
  36.          */
  37.         void MakeEmpty(void);       // empties the stack
  38.         bool IsEmpty(void);         // returns true if the stack is empty
  39.         bool IsFull();              // returns true if the stack is full
  40.  
  41.  
  42.     /**
  43.      * Everything under protected can be accessed only by the class itself or (derived) subclasses,
  44.      * as in the case of inheritance.
  45.      */
  46.     protected:
  47.  
  48.  
  49.     /**
  50.      * (Private) DATA MEMBERS/PROPERTIES:
  51.      *
  52.      * Everything under private can only be accessed by the class itself (the code in the
  53.      * implementation file).
  54.      */
  55.     private:
  56.         int     top;                // a value representing the top of the stack
  57.         float   data[MAX_LENGTH];   // the array to be used as the (LIFO) stack
  58. };
  59.  
  60. #endif // ARRAYBASEDSTACK_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement