sorry about my english. I'm trying to do and simple example of raise an exception when input wrong data type in c++, like this in Python:
try:
x=float(input("Input a real number:"))
print("Your input:", x)
except ValueError:
print("Error in data type!, need to be a real number, not char ")
can help me? Thank you in advance.
Well, I found an answer. In c++ don´t need rise an exception like in Python. I propoust this solution, is not perfect, but is close. I say close, because if you input 2,35 ( not 2.35) the output is 2, and it isn't ok, because dot (.) is correct in decimal number, not ( , ) .