3 ms·
It shouldn't be valid in C++. booleans cannot participate in arithmetic operations. You will get a warning from the compiler if you are lucky. C doesn't have b
by user5994461 8y ago
It shouldn't be valid in C++. booleans cannot participate in arithmetic operations. You will get a warning from the compiler if you are lucky.
C doesn't have booleans and treat them as integers 0 or 1, it can do the math and will always return 1.
- comex 8y agoThat's not true. C++ does define an implicit conversion from bool to int: https://en.cppreference.com/w/cpp/language/implicit_conversion https://en.cppreference.com/w/cpp/language/implicit_conversi... (under "Integral promotion") And C has a boolean type as of C99.