I woud like to ask what is return value of cin? I know it is istream object and when it is used in expression like if(!cin)
there is actually called some function and I woud like to know what function it actually is. cin.fail() or cin.good() or..
Is if(!cin) same as if(cin.fail())?
-
stackoverflow.com/questions/5695146/…– Suvarna PattayilOct 15, 2013 at 15:35
Add a comment
|
1 Answer
Yes.
cin
overloads casting operators, and they return flag status fail()
.
A possible implementation:
operator void*() const {
return !fail();
}
explicit operator bool(){
return !fail();
}
bool operator!() const {
return fail();
}