------------------------------------------------------------------------------
MC logo
C++ Integer Stack Implementation
[^] Code Examples
------------------------------------------------------------------------------
<<C++ Integer Stack ADT istack2.cc C++ Integer Stack Driver>>
#include "istack2.h"

// Pop and return an integer.
int IntStack::pop()
{
        int ret = head->val;
        node *oldhead = head;
        head = head->next;
        delete oldhead;
        return ret;
}

// Print the stack on the stream.
void IntStack::print(ostream &strm) const
{
        strm << "[< ";
        if(head) head->printall(strm);
        strm << ">]";
}
<<C++ Integer Stack ADT C++ Integer Stack Driver>>