------------------------------------------------------------------------------
MC logo
C++ Integer Stack Implementation
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Point Hdr File] [Point Impl File] [Point User File] [Point Class Hdr File] [Point Class Impl File] [Point Class User File] [C++ Integer Stack ADT] [C++ Integer Stack Implementation] [C++ Integer Stack Driver]
istack2.cc
#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 << ">]";
}