Bounded Array Driver
#include "bsafearr.h" main() { // Create one bounded safe array. BoundedSafeArr<int> bsia(3,9); cout << "Created bounded array size " << bsia.size() << ", range " << bsia.get_low() << ".." << bsia.get_hi() << endl; // Fill it up with some subscript errors. for(int i = 2; i <= 10; ++i) try { bsia.store(i, 3*i-10); } catch(out_of_range &e) { cout << "Error: " << e.what() << endl; } // Print contents with some subscript errors. for(int i = 10; i >= 2; --i) try { cout << i << ": " << bsia.fetch(i) << endl; } catch(out_of_range &e) { cout << "Error: " << e.what() << endl; } // Demonstrate some properties of assignment. BoundedSafeArr<int> 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; }