why it is not returning bool | Sololearn: Learn to code for FREE!


why it is not returning bool

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

7/25/2017 9:13:29 AM


3 Answers

New Answer


... As a matter of fact, yes. bool test = true; std::cout << std::boolalpha << test; // outputs true


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.


@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.