// Exceptions.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #include #include #include #include using namespace std; void print(int i) { cout << i << endl; }; int main() { try { //wrapping potential source of exception vector v; //reminder about the vector v.push_back(1); v.push_back(2); v.at(3); } //whatever exceptions happen in this block the programm is going to the catch statement catch (out_of_range& e) //we get caught specific exception, that catch blocks everything else afterwards { cout << "out_of_range" << e.what() << endl; } catch (exception & e) //We caught just any exception here { cout << "something else" << e.what() << endl; } system("pause"); return 0; }