Please correct me on my translation of this code.
Is the following translation accurate?
Code:
#include <limits> // Add this for numeric_limits
...
if ( !( cin>> y ) ) {
cin.clear(); // Clear the errors
cin.ignore ( numeric_limits<streamsize>::max(), '\n' );
cerr<<"Invalid input, try again: ";
}
Translates to if the data inputed into y doesn't match the data type y was declared as then execute the following statements.
A follow up question is what does the header limits do?
Does it hold the details of the following code?
Code:
numeric_limits<streamsize>::max()