A Boolean type (BOOL) is a new basic data type added by C + +. The bool type is not defined in the standard C language, and if you need to use the bool type, the programmer can customize a bool type with a macro definition, which defines the following statement:
- #define bool int
Le View account update
- #define FALSE 0
- #define TRUE 1
That is, the int type is defined as bool, and the int type 0 and 12 values are defined as two values of type bool, true and false.
June 27 PPS Update
But in C + + it doesn't have to be so cumbersome, and C + + has a definition of bool type.
The bool type is one of the basic data structures of the C + + language, where the compiler gcc 4.8.1 and Visual C + + 2012 assign a 1-byte length to the BOOL type variable on the 80x86 processor. The bool type takes a value range of only two values: True and False. When you do a logical operation, the default nonzero is ture.
Defining a BOOL type variable is also similar to the definition of other basic data type variables, as follows:
C + + Boolean type (BOOL)