Safe Array Driver
#include <iostream> #include "gsafearr3.h" using namespace std; main() { SafeArr<double> a1(6); try { for(int i = 0; i < 6; ++i) a1.store(i, 4.6*i - 6.44); } catch(exception &e) { cout << string("Error (part 1): ") + e.what() << endl; } cout << "p1: " << a1 << endl; try { a1.store(2, -5.7); a1.store(10, 73.8); a1.store(-1, 8.8); } catch(exception &e) { cout << string("Error (part 2): ") + e.what() << endl; } try { cout << "fetches: " << a1.fetch(4) << " " << a1.fetch(10) << " " << a1.fetch(2) << " " << a1.fetch(-1) << endl; } catch(exception &e) { cout << string("Error (part 3): ") + e.what() << endl; } cout << "p1: " << a1 << endl; }