I don't quite understand the working and the use of this code.
I have tried giving 'null' as an input to terminate this while loop, but still not sure how it functions in a program.
while (cin >> x) {
code
}
I don't quite understand the working and the use of this code.
I have tried giving 'null' as an input to terminate this while loop, but still not sure how it functions in a program.
while (cin >> x) {
code
}
The definition of the std::cin's "operator >>" is (roughly):
template<class T>
istream& operator>> (const T& val);
After calling '>>' an istream& will always be returned which will than evaluate to 'true' in the while loop. Therefor this program will not terminate until some type of exception is thrown.