#include #include #include using namespace std; void checkAndPrint(int a) throw (string) // throw tells that // an exception of // type string will // be thrown. { if ((a < 10)|| (a>100)) throw string("Number out of range"); cout << a << endl; } int main() { try { ifstream fin; fin.open("C:\\numbers.txt"); if (fin.fail()) throw static_cast("Opening file failed."); int a; fin >> a; checkAndPrint(a); } catch (int i) { cout << "The int-error was " << i << endl; } catch (string s) { cout << "The string-error was " << s << endl; } return 0; }