stack.h 621 B

12345678910111213141516171819202122
  1. // stack.h -- class definition for the stack ADT
  2. #ifndef STACK_H_
  3. #define STACK_H_
  4. typedef unsigned long Item;
  5. class Stack
  6. {
  7. private:
  8. enum {MAX = 10}; // constant specific to class
  9. Item items[MAX]; // holds stack items
  10. int top; // index for top stack item
  11. public:
  12. Stack();
  13. bool isempty() const;
  14. bool isfull() const;
  15. // push() returns false if stack already is full, true otherwise
  16. bool push(const Item & item); // add item to stack
  17. // pop() returns false if stack already is empty, true otherwise
  18. bool pop(Item & item); // pop top into item
  19. };
  20. #endif