Hi,
Boolean values are represented in C++ by the bool data type. True is stored
as 1 and false as 0. I believe that Pascal uses -1 for true and 0 for false.
This is what Borland C++ Builder help says:
-----------------------------------------------------------
Use bool and the literals false and true to perform Boolean logic tests.
The bool keyword represents a type that can take only the value false or
true. The keywords false and true are Boolean literals with predefined
values. false is numerically zero and true is numerically one. These Boolean
literals are rvalues; you cannot make an assignment to them.
You can convert an rvalue that is of type bool to an rvalue that is int
type. The numerical conversion sets false to zero and true becomes one.
You can convert arithmetic, enumeration, pointer, or pointer to member
rvalue types to an rvalue of type bool. A zero value, null pointer value, or
null member pointer value is converted to false. Any other value is
converted to true.
---------------------------------------------------------
Kev.
----- Original Message -----
From: David Mcken <ci...@ya...>
To: <dev...@li...>
Sent: Wednesday, January 16, 2002 6:28 PM
Subject: [Dev-C++] help with bool
> I have been told that boolean logic is represented
> by using numbers yet when I type bool I see it bold.
> Will some one please tell me if there is a type bool and
> what states it uses (ex. true or false, or dose it still accept
> numbers
> for now I have been putting this at the beginning of all my code
> //Define True and False
> #define false 0
> #define true !false
> I am a newbie just out of high school in the Caribbean and I
> am looking to advance my skills in C and C++ (for now all I
> know is Turbo Pascal which has a boolean type)
>
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|