/* Compile with /EHsc */ #include #include using namespace std; int main() { const int n=10; vector x(10); x = {1,2,3,4,5,6,7,8,9,10}; for (int i : x) { cout << i << endl; } try { cout << " [] access " << endl; cout << x[20] << endl; } catch ( exception &e ) { cerr << "Caught: " << e.what( ) << endl; }; try { cout << " .at() access " << endl; cout << x.at(20) << endl; } catch ( exception &e ) { cerr << "Caught: " << e.what( ) << endl; }; return(0); }