3

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())?

1

1 Answer 1

1

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();
}

Look at here and here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.