= 56 (Just a random Number too)
What Will that be? A true?
It depends on the language and if the language allows truthy and falsy values (google these terms). Also the above assignment depends on how strict the type system is. Some languages won't allow bools to be assigned anything other than true or false. (Google these terms: implicit conversion / coercion)
I don't know different version of compilers might take it differently... But in C++ anything above the value of 0 is true... so 1 is true and 2 is true too and so is 56. Even -ev values are true, so -56 will also be true. Only 0 is false.
There'll be a conversion there though. If the OP used Bool random_variable { 56 }; (which is to me the right way of initialization most f the time) they'd be aware of that.
Обсуждают сегодня