It's been confusing before. C + + with >>, getline and other functions to read data, such as:
while (CIN>>C) or while (Getline (CIN, str))
Why is it possible to read directly the end of the data or read the data error, which is equivalent to returning a bool type
Because I see the function its prototype is like this, return is a istream&
istream& operator>> (bool& val);
istream& operator>> (short& val);
istream& operator>> (unsigned short& val);
istream& operator>> (int& val);
istream& operator>> (unsigned int& val);
istream& operator>> (long& val);
istream& Getline (istream& is, string& str, char delim);
istream& Getline (istream& is, string& str);
The original is its parent class Basic_ios implemented the following two functions, haha, finally understand:
@{
/**
* @brief the quick-and-easy status check.
*
* This allows your to write constructs such as
* "if (!a_stream) ..." and "while (A_stream) ..."
*/
operator void* () const
{return This->fail (): 0:const_cast<basic_ios*> (this);}
BOOL
operator! () const
{return this->fail ();}
//@}