class StackInterface
1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: /** @file StackInterface.h */
6: #ifndef _STACK_INTERFACE
7: #define _STACK_INTERFACE
9: template<class ItemType>
10: class StackInterface
11: {
12: public:
13: /** Sees whether this stack is empty.
14: @return True if the stack is empty, or false if not. */
15: virtual bool isEmpty() const = 0;
16:
17: /** Adds a new entry to the top of this stack.
18: @post If the operation was successful, newEntry is at the top of the stack.
19: @param newEntry The object to be added as a new entry.
20: @return True if the addition is successful or false if not. */
21: virtual bool push(const ItemType& newEntry) = 0;
22:
23: /** Removes the top of this stack.
24: @post If the operation was successful, the top of the stack
25: has been removed.
26: @return True if the removal is successful or false if not. */
27: virtual bool pop() = 0;
28:
29: /** Returns the top of this stack.
30: @pre The stack is not empty.
31: @post The top of the stack has been returned, and
32: the stack is unchanged.
33: @return The top of the stack. */
34: virtual ItemType peek() const = 0;
35: }; // end StackInterface
36: #endif