cin
is an instance of istream
template class. operator >>
acts on this istream instance to load input into data and returns a reference to this istream
. Then in while
condition it is tested by a call to cin::operator void*() const
(explicit operator bool() const
in C++11) which invokes fail()
function to test if operation succeeded. This is why you can use this operation in while condition
while ( cin >> x)
{
//...