I know I can use cin >>as a condition. But I can't understand its functioning because it is unlike typical condition expressions like a a < b.
Why it can works as a condition ?
            Asked
            
        
        
            Active
            
        
            Viewed 119 times
        
    0
            
            
        
        tsrrhhh
        
- 459
 - 1
 - 5
 - 10
 
- 
                    `std::iostream::operator>>` returns a value. Values can be used in conditions. – jamesdlin Mar 27 '17 at 09:13
 - 
                    To be more precise: Values that are convertible to boolean can be used in conditions. – eerorika Mar 27 '17 at 09:16
 
1 Answers
2
            cin >> a return cin. When you put in in the if, the operator bool of istream is called, which return cin.good(). Look at The documentation of ios::operator bool.
This is the same as if((bool)(cin >> a)) or if((cin >> a).good()).