Rename members of StackArray
This commit is contained in:
parent
44d4e2265c
commit
8af7c295c6
|
@ -14,14 +14,14 @@ class StackArray {
|
|||
|
||||
private:
|
||||
enum { EMPTY=-1, MAX=10 };
|
||||
class ListNode {
|
||||
class Node {
|
||||
public:
|
||||
ListNode() : next(NULL) {};
|
||||
ListNode(char val) : data(val), next(NULL) {};
|
||||
Node() : next(NULL) {};
|
||||
Node(char val) : data(val), next(NULL) {};
|
||||
char data;
|
||||
ListNode* next;
|
||||
Node* next;
|
||||
};
|
||||
ListNode list[MAX];
|
||||
Node stack[MAX];
|
||||
int top;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ void StackArray::Push(char val)
|
|||
{
|
||||
|
||||
if (top < MAX && !isEmpty()) {
|
||||
this->list[++top].data = val;
|
||||
this->stack[++top].data = val;
|
||||
}
|
||||
else if (isEmpty()) {
|
||||
this->list[++top].data = val;
|
||||
this->stack[++top].data = val;
|
||||
}
|
||||
else {
|
||||
std::cout << "Error: List is full!\n";
|
||||
std::cout << "Error: stack is full!\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ char StackArray::Pop()
|
|||
|
||||
char StackArray::Top() const
|
||||
{
|
||||
return this->list[top].data;
|
||||
return this->stack[top].data;
|
||||
}
|
||||
|
||||
void StackArray::Display() const
|
||||
|
@ -40,8 +40,8 @@ void StackArray::Display() const
|
|||
|
||||
int tempTop = this->top;
|
||||
while (tempTop >= 0) {
|
||||
std::cout << "Value at list [" << tempTop << "]: "
|
||||
<< this->list[tempTop].data << std::endl;
|
||||
std::cout << "Value at stack [" << tempTop << "]: "
|
||||
<< this->stack[tempTop].data << std::endl;
|
||||
tempTop--;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue