// File: vtest3.cpp // // Vectors can throw exceptions too. #include #include #include #include "twodim13.h" using namespace std ; int main() try { vector V(5) ; TwoDimArray A(5,5) ; // V.at(9) = 17 ; A[5][4] = 17 ; // throw "a party" ; //} catch (OutOfBounds) { // cerr << "Caught the TwoDimArray exception\n" ; // //} catch (out_of_range &e) { // cerr << "Caught vector exception\n" ; // cerr << e.what() << "\n" ; } catch (runtime_error &e) { cerr << "Caught runtime_error exception\n" ; cerr << e.what() << "\n" ; } catch (exception &e) { cerr << "Catch anything derived from exception!\n" ; cerr << e.what() << "\n" ; } catch (...) { cerr << "Catch anything at all\n" ; }