//stack1.cpp //methods for class Stack implemented using nodes #include #include #include "stack1.h" Stack::Stack() { top = NULL; } Stack::~Stack() { Node *p, *q; p = top; while(p) { q = p; p = p->getnext(); delete q; } } int Stack::isempty() { return top == NULL; } void Stack::push(Type x) { Node *p = new Node; assert(p); p->setinfo(x); p->setnext(top); top = p; } Type Stack::pop() { Node *p; Type x; assert(!isempty()); p = top; x = p->getinfo(); top = p->getnext(); delete p; return x; } void Stack::print() { Node *p; p = top; while(p) { cout<getinfo()<<' '; p = p->getnext(); } cout<