Stack::Stack(const Stack& stack) {
SNode *p = stack.top;
top = (SNode*)0;
// get a reversed stack
while(p) {
Push(p->data);
p = p->next;
}
// reverse it again
p = top;
top = (SNode*)0;
SNode* del;
while(p) {
Push(p->data);
del = p;
p = p->next;
delete del;
}
}
Thursday, October 22, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment