//linked stack implementation template class LStack: public Stack { private: Link* top; int size; public: LStack(int sz =defaultSize) { top = NULL; size=sz; } ~LStack() { clear(); } void clear() { while (top != NULL) { Link* temp = top; top = top->next; delete temp; } size=0; } void push(const E& it) { top = new Link(it top); size++; } E pop() { Assert(top != NULL, "stack is empty"); E it = top->element; Link* ltemp = top->next; delete top; top = ltemp; size--; return it; } const E& topValue() const { Assert(top != 0, "stack is empty"); return top->element; } int length() const { return size; } };