MC logo
C++ Integer Stack Driver
[^] 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]
#include <iostream>
#include "istack2.h"

using namespace std;

        // Declare two stacks (not references)
        IntStack s, t;

        // Read in and stack some integers.
        int in;
        while(cin >> in) {

        // Print out one of the stacks.
        cout << s << endl;

        // Empty the stack printing its members.
        while(! s.empty())
                cout << "[" << s.pop() << "]" << endl;

        // Print the other stack.
        cout << t << endl;