------------------------------------------------------------------------------
MC logo
Bounded Safe Array 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]
[Bounded Safe Array] [Bounded Safe Array Driver] [PrintMe Class] [PrintMe2 Class] [PrintMeLots Class] [PrintMeLots2 Class] [PrintMe Test Driver] [Linked List Node Classes] [Linked List Classes] [Linked List Implementation] [Linked List Driver] [Expression Calculator]
bsarun.cpp
#include "safearr.h"
#include "bsafearr.h"

main()
{
        // Create one bounded safe array.
        BoundedSafeIntArr bsia(3,9);

        // Fill it up with some subscript errors.
        for(int i = 2; i <= 10; ++i)
                bsia.store(i, 3*i-10);

        // Printe contents with some subscript errors.
        for(int i = 10; i >= 2; --i)
                cout << i << ": " << bsia.fetch(i) << endl;

        // Demonstrate some properties of assignment.
        BoundedSafeIntArr bsia2(14, 44), bsia3(bsia);
        bsia2 = bsia;
        cout << bsia2.get_low() << " " << bsia2.get_hi() << " " 
             << bsia3.get_low() << " " << bsia3.get_hi() << endl;
        bsia2.store(5, 999);
        cout << bsia.fetch(5) << endl;
}