#include #include using namespace std; void health(const istream& is); int main() { health(cin); cin.setstate(ios_base::failbit); health(cin); return EXIT_SUCCESS; } void health(const istream& is) { const ios_base::iostate state = is.rdstate(); cout << "eof returns " << is.eof() << ", eofbit is " << static_cast(state & ios_base::eofbit) << "\n" << "bad returns " << is.bad() << ", badbit is " << static_cast(state & ios_base::badbit) << "\n" << "fail returns " << is.fail() << ", failbit is " << static_cast(state & ios_base::failbit) << "\n" << "good returns " << is.good() << "\n" << "operator void * returns " << is.operator void *() << "\n" << "operator! returns " << is.operator!() << "\n\n"; }