#include "mydefs2a.h" #include #include // Linked list implementation of stacks. Istack :: node* Istack :: new_node(int d, node* n) { node* t = new node; assert( t ); t -> data = d; t -> next = n; return( t ); } int Istack :: pop() { assert( !isempty() ); int t = top -> data; node* oldtop = top; top = top -> next; delete oldtop; return t; } void main() { Istack s1, s2; int i; s1.init(500); s2.init(); for( i = 0; i < 20; i++ ) { s1.push(i); } for( i = 0; i < 20; i++ ) { cout << s1.pop() << ' '; } cout << endl; s2.push(10); i = s2.pop(); }