Boolean values: Difference between revisions

Content deleted Content added
slight goof
Ce (talk | contribs)
Line 16:
 
QuickBasic has no keywords for true and false. Boolean expressions evaluate to 0 when false, and a non-zero value when true. Numbers also work in place of boolean expressions following those rules.
 
=={{header|C++}}==
In C++, there are the constants <code>true</code> and <code>false</code> to represent those values. However, there are numerous implicit conversions to <code>bool</code>, therefore in conditions (and other contexts expecting boolean values), any of the following can be used:
* any integer type, where 0 converts to false, and any other value converts to true (note that in C++, character types are also integer types, therefore this also applies to characters)
* any floating point type, where again, 0 gives false and everything else gives true
* any enumeration type, again 0 gives false, anything else true
* any pointer type, where the null pointer gives false and any other pointer gives true
* any user-defined type with an implicit conversion operator either to <code>bool</code> or to a built-in type which itself can be converted to <code>bool</code> (i.e. any of the above). The C++ standard library contains one such implicit conversion: the implicit conversion of a stream <code>s</code> to <code>bool</code> gives <code>!s.fail()</code>
 
=={{header|E}}==