I thought that:
if (true) {execute this statement}
So how does if (std::cin >> X) execute as true when there is nothing
if (std::cin >> X)
if(x) is equivalent to if(bool(x))
if(x)
if(bool(x))
in this case bool(x) calls std::istream::operator bool(x)
bool(x)
std::istream::operator bool(x)
this will return:
true if none of failbit or badbit is set. false otherwise.
true if none of failbit or badbit is set.
failbit
badbit
false otherwise.