How can I catch a exception were I'm expecting an integer but the user enters a real or string.
Can someone give me a list of the basic exceptions that can be caught?
I know the format of catching them is as follows, but what do you put in the parenthesis of the catch bit, in Java you code something like catch(NumberFormatException exp) to catch number entry errors etc.
Bellow is a small test piece of the project I'm doing and I wish to catch an exception when the users entry is taken at the 'cin' bit.Code:try { // statements } catch() { // statements }
Code:int menu() { int selectedOption = 0; do { clearScreen(); cout << "MAIN MENU" << endl; cout << "<1> Option A" << endl; cout << "<2> Option B" << endl; cout << "<3> Option C" << endl; cout << "<4> Option D" << endl; cout << "<5> Option E" << endl; cout << "\nEnter selection: "; cin >> selectedOption; } while((selectedOption < 1) || (selectedOption > 5)); return selectedOption; }




Reply With Quote