1try {
2 //do something
3} catch (const std::exception& e) {
4 std::cout << e.what(); // information from error printed
5}
1// exceptions
2#include <iostream>
3using namespace std;
4
5int main () {
6 try
7 {
8 throw 20;
9 }
10 catch (int e)
11 {
12 cout << "An exception occurred. Exception Nr. " << e << '\n';
13 }
14 return 0;
15}