How integers are converted to boolean type
Anything other than 0 is coverted to true
#include<iostream>int main() {bool b1,b2,b3,b4,b5,b6;b1 = -1;b2 = 1;b3 = 0;b4 = 244;b5 = true;b6 = false;std::cout << "b1 : " << b1 << "\n";std::cout << "b2 : " << b2 << "\n";std::cout << "b3 : " << b3 << "\n";std::cout << "b4 : " << b4 << "\n";std::cout << "b5 : " << b5 << "\n";std::cout << "b6 : " << b6 << "\n";return 0;}
Output
./a.outb1 : 1b2 : 1b3 : 0b4 : 1b5 : 1b6 : 0