// File: genstack.C // // Implementation of GenStack class, which is derived from GenQ #include #include #include #include "genstack.h" // Constructor. No default constructor! // GenStack::GenStack(GenQ::GQcmp cmp_func, GenQ::GQprt prt_func) : GenQ(cmp_func, prt_func) // member initializer { #ifndef NDEBUG cerr << "GenStack constructor, this = " << this << endl ; #endif // Do nothing } // Destructor // GenStack::~GenStack() { #ifndef NDEBUG cerr << "GenStack destructor, this = " << this << endl ; #endif // Do nothing, GenQ destructor automatically called } // Add item to the top of the stack // void GenStack::push(void *ptr) { QCell *q = newcell() ; q->data = ptr ; q->next = dummy.next ; dummy.next = q ; len++ ; if (q->next == NULL) last = q ; }