------------------------------------------------------------------------------
MC logo
Array Template Test 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]
[Template Functions] [Template Generalized Stack] [Template Generalized Stack Driver] [Array Template Stack] [Array Template Test Driver] [Generalized Safe Array] [Safe Array Demo] [Vector Iterator Demo]
stackt2use.cc
#include <iostream>
#include <string>
#include "stackt2.h"

using namespace std;

main()
{
        // Make a stack of integers.
        Stack<int, 30> is;
        int n;

        cout << "Enter integers to -1:" << endl << "> ";
        while(cin >> n)
        {
                if(n == -1) break;
                is.push(n);
                cout << "> ";
        }

        while(!is.empty())
                cout << is.pop() << " ";
        cout << endl;

        // Make a stack of strings.
        Stack<string> ss;
        string s;

        cout << "Enter lines to EOF:" << endl << "> ";
        cin.clear();
        getline(cin,s);
        while(getline(cin,s))
        {
                ss.push(s);
                cout << "> ";
        }

        cout << endl;
        while(!ss.empty())
                cout << ss.pop() << endl;
}