------------------------------------------------------------------------------
MC logo
Bounds Error Demo
[^] 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]
[Safe Integer Array Class] [Safe Integer Array Implementation] [Bounds Error Demo] [Object Copy Demo] [No Copies For Me, Please] [Hidden Calls]
bounderr.cpp
#include <iostream>
#include "safearr.h"

using namespace std;

main()
{
        SafeIntArr a1(6);

        for(int i = 0; i < 6; ++i)
                a1.store(i, 3*i + 2);
        cout << "p1: " << a1 << endl;

        a1.store(2, -5);
        a1.store(10, 71);
        a1.store(-1, 88);
        cout << "fetches: " << a1.fetch(4) << " " << a1.fetch(10) << " "
             << a1.fetch(2) << " " << a1.fetch(-1) << endl;

        cout << "p1: " << a1 << endl;
}