0
What happens if the user entera a different data type than the expected one (for instante a char instead of an int)?
4 ответов
+ 1
The compiler can't accept the value.
+ 1
Since the "user" is the one who enters the wrong value, the compiler will NOT warn you. The compiler turns your C++ code into object code, then the linker puts all your object code plus any declared dependencies into an executable that the user runs.
To cut to the point, YOU have to check if the user's input is what you should accept or not. If you are expecting an int, but the user enters a char, you have to check the value before trying to store their input into a int variable, either using a try catch block or by parsing the input to make sure is just numbers.
+ 1
Use try-catch :-)
0
The compiler is warn you. It will use entered variable`s memory address for expected variable type. So, writen variable will be used expected type.