home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_07 / 8n07071a < prev    next >
Text File  |  1990-06-19  |  574b  |  30 lines

  1.  
  2.  
  3. typedef int Boolean;
  4. const Boolean TRUTH = 1;
  5. const Boolean FALSE = 0;
  6.  
  7. const int dim = 10;
  8.  
  9. class Stack {
  10. public:
  11.     // initialize stack to sane state
  12.     Stack()           { index = 0; }
  13.  
  14.     // push a int value
  15.     void push(int x)  { data[index++] = x; }
  16.  
  17.     // remove top value and return it
  18.     int pop()         { return data[--index]; }
  19.  
  20.     // returns true if empty
  21.     Boolean isempty() { return index == 0;
  22.  
  23.     // returns true if full
  24.     Boolean isfull()  { return index >= dim; }
  25. private:
  26.     int index;
  27.     int data[dim];
  28. };
  29.  
  30.