class ArrayStack
1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: /** ADT stack: Array-based implementation.
5: Listing 7-1
6: @file ArrayStack.h */
8: #ifndef ARRAY_STACK_
9: #define ARRAY_STACK_
11: #include "StackInterface.h"
13: const int MAX_STACK = 5;
15: template<class ItemType>
16: class ArrayStack : public StackInterface<ItemType>
17: {
18: private:
19: static const int DEFAULT_CAPACITY = 50;
20: ItemType items[DEFAULT_CAPACITY]; // Array of stack items
21: int top; // Index to top of stack
22:
23: public:
24: ArrayStack(); // Default constructor
25: bool isEmpty() const;
26: bool push(const ItemType& newEntry);
27: bool pop();
28: ItemType peek() const;
29: }; // end ArrayStack
31: #include "ArrayStack.cpp"
32: #endif