How to use Try, Catch, Throw?

Hi!, i've been researching a bit about this topic but it's been a little hard for me to learn how to use the try catch and throw.

I want to validate a value entered by a user, in this case his/her ID, and i want to validate if the values entered are all numbers
1
2
3
4
5
string ID;

cout<<"Enter your ID"<<endl;
cin>>ID;


So if the user tipes a letter it would say:

 
cout<<"invalid ID please try again"<<endl;


I just want a simple example so i can learn how to use it, thanks in advance
Last edited on
For what you're doing here you're better off using the cctype header: http://www.cplusplus.com/reference/clibrary/cctype/

Exceptions are more for error handling.
Topic archived. No new replies allowed.