Catch type error in C ++
3 answers
Could you please give more details on what gives you the "result", you can determine what you need from there, and more likely in a better way.
If you really want to check the type, use typeid
. More details here
Following Daniel's post editing model to actually answer the question by pointing out something else ...
From my other comment:
You must do this before you simply have a result. Checking for overflow after is not a good idea. Check for numbers before adding to see if they will overflow or limit input should be less than half the maximum value type
+4
source to share