SHOW:
|
|
- or go back to the newest paste.
1 | //============================================================= stack.h ====== | |
2 | //= C++ class for a stack of integers data structure | |
3 | //============================================================================ | |
4 | //= Make: Not Applicable | |
5 | //= Exec: Not Applicable | |
6 | //=--------------------------------------------------------------------------- | |
7 | //= Notes: See stack.cpp for member functions | |
8 | //=--------------------------------------------------------------------------- | |
9 | //= History: KJC (09/27/16) - Originate | |
10 | //============================================================================ | |
11 | class stack | |
12 | { | |
13 | private: | |
14 | int *s_array; // Array of intergers for stack | |
15 | int size; // Size of stack | |
16 | int top; // Pointer to top element in stack | |
17 | ||
18 | public: | |
19 | stack() {} // Default constructor | |
20 | stack(int length); // Constructor allocates memory for s_array | |
21 | int get_top(void); // Returns pointer to top (-1, ... size - 1) | |
22 | void push(int x); // Pushes x onto stack | |
23 | int pop(void); // Pops and returns popped value | |
24 | ~stack(void); // Destructor frees memory for s_array | |
25 | }; |