#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 string("Opening file failed."); int a; fin >> a; checkAndPrint(a); } catch (string errorMessage) { cout << "The error was: " << errorMessage << endl; } return 0; }