Monday, 26 August 2013

Preventing implicit conversion in C++

Preventing implicit conversion in C++

I ask the user for an integer input and I do not want to execute code
unless it is strictly an integer.
int x;
if(cin >> x)
For instance if the user inputs a double above, the if statement will
execute with implicit conversion to an integer. Instead I don't want the
code to execute at all.
How can I prevent this?

No comments:

Post a Comment