class ArrayStack
1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
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: ItemType items[MAX_STACK]; // Array of stack items
20: int top; // Index to top of stack
21:
22: public:
23: ArrayStack(); // Default constructor
24: bool isEmpty() const;
25: bool push(const ItemType& newEntry);
26: bool pop();
27: ItemType peek() const;
28: }; // end ArrayStack
30: #include "ArrayStack.cpp"
31: #endif