I'm trying to get input from a user, put that input into a string, then check the string to see if it is an integer value. I have been searching all over the C++ reference, looking at stringstream, atoi and typeinfo, but I haven't been able to figure out how to throw an exception if the user inputs "f".
This code doesn't compile, but I think it demonstrates what I want to accomplish:
I've looked over some tutorials on how to convert string to int, but none have showed how to throw an exception if anything other than a number is used. Any advice is much appreciated.