0
why it is not returning bool
https://code.sololearn.com/cHqxjRiO48hy/?ref=app why year() is not returning bool and instead returning 1.
3 odpowiedzi
+ 10
... As a matter of fact, yes.
bool test = true;
std::cout << std::boolalpha << test;
// outputs true
+ 9
In C++, 1 (or any other value other than 0 casted to bool) is true, and 0 is false.
if (1) and if (true) is the same thing.
tl;dr - C++ will display boolean values as 1 or 0.
+ 1
@hatsey how we can get normal true or false. can we yes we can use these as well but is there a way to do so.