Node *top_node;
}
Sau đó là các đoạn code cho các hàm trong Stack như sau:
Stack_entry Stack::push(const Stack_entry &item)
{
Node *new_top = new Node(item, top_node);
if (new_top == NULL) return 0;
top_node = new_top;
return item;
}
/********************************************************
************/
Error_code Stack::pop()
{
Node *old_top = top_node;
if (top_node == NULL) return underflow;
top_node = old_top->next ;
delete old_top;
count--;
return success;
}
/********************************************************
***********/
Stack_entry Stack::top(Stack_entry &item) const
{
if (top_node == NULL) return 0;
item = top_node->entry;
return item;
}
/********************************************************