Hi everyone!
im writing a code, and im requested to use execptions.
my question- where do i put the "throw" calls? in the main> in the function? in the class?
and the same for the "try" call.
for example- part of my code:
1 2 3 4 5
//Main
cout<<"Insert product's serial number, composed of 5 integers: ";
cin>>serial;
cout<<endl<<"Insert product's quantity(weight at stock, at least 1).";
cin>>quantity;
must i write try&catch for each of the cases? or there is option to do one try for all cases? in addition, i want that if wrong input had recieved, the code would have scanned another values, untill it is correct. how do i do this?
You don't need exceptions/try/catch with input handling. If you want to repeatedly ask the user to enter valid input, read http://www.LB-Stuff.com/user-input
You only throw exceptions where you don't know how to recover from an error.
You only catch exceptions where you do know how to recover from an error.