-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.h
More file actions
31 lines (24 loc) · 671 Bytes
/
Stack.h
File metadata and controls
31 lines (24 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef __Stack__H
#define __Stack__H
#include <string>
using namespace std;
typedef string StackItemType;
class Stack {
public:
Stack();
Stack(const Stack& aStack);
~Stack();
bool isEmpty() const;
bool push(const StackItemType newItem);
bool pop();
bool pop(StackItemType& stackTop);
bool getTop(StackItemType& stackTop) const;
//void reverseStack(StackItemType& stack) const;
private:
struct StackNode { // a node on the stack
StackItemType item; // a data item on the stack
StackNode* next; // pointer to next node
};
StackNode* topPtr; // pointer to first node in the stack
};
#endif