0

why it is not returning bool

https://code.sololearn.com/cHqxjRiO48hy/?ref=app why year() is not returning bool and instead returning 1.

25th Jul 2017, 9:13 AM
shobhit
shobhit - avatar
3 Answers
+ 10
... As a matter of fact, yes. bool test = true; std::cout << std::boolalpha << test; // outputs true
25th Jul 2017, 9:45 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
25th Jul 2017, 9:15 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
25th Jul 2017, 9:39 AM
shobhit
shobhit - avatar