I’m looking for a way to switch between an if and an else block when an error occurs. For example:
cout << "Enter 1 or 2 as your choice...";
cin >> choice;
if(choice==1) {
//do something here
//if error occurs....
} else if(choice==2) {
//switch to this else block
}
I’ve played around with try/throw/catch but it appears that the catch has to follow the try statement. Any ideas/suggestions would be appreciated!
Looks like you could just not have an “else”: