// File: vtest4.cpp // // Vectors can throw exceptions too. #include #include #include #include "twodim14.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 out_of_range exception\n" ; cerr << e.what() << "\n" ; } catch (logic_error &e) { cerr << "Caught logic_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" ; }