Does anyone know why istream object can be used as bool expression? For example:
ifstream input("tmp");
int iValue;
while (input >> iValue)
//do something;
Here input >> iValue
returns a reference to the ifstream object. I want to know why this object can be used as a bool expression.
I look into the ifstream class and find that this may be due to the following member function:
operator void * ( ) const;
See here for detail about this function.
If it is, can anyone explain this function to me? The prototype of this function is different from usual operator overload declaration. What is the return type of this function?
If it is not, then what is the reason that ifstream object can be used as bool expression?
Looking forward to your help!
cheng