- Bool Definition
Typedef int bool;
# Define false 0
# Define true 1
It cannot be fully overloaded (bool is essentially INT), for example:
// File. h void F (INT); // OK
Void F (bool); // OK //
File. cpp
Void F (INT ){/*.... * //} // OK
Void F (bool ){/*.... */} // Error, re-declare
- Bool (false, true) is a built-in C ++ type, which can avoid the above problems.
Bool occupies 1 byte in C ++, while bool is of the int type. The size of the int type depends on the specific environment. So: false/true only occupies 1 byte, while True/false depends on the specific environment.
The following is the definition of bool in windef. h:
Typedef int bool;
False/true is the new keyword in the Standard C ++ language, while false/true is solved through # define.ProgramIn the differences between C and C ++ environments, the following is the definition of false/true in windef. h:
# Ifndef false
# Define false 0
# Endif
# Ifndef true
# Define true 1
# Endif
That is to say, false/true is the int type, while false/true is the bool type. So they are different, but we do not feel this way in use, because C ++ will help you perform implicit conversion.
In Linux, the C ++ compiler must use g ++. Otherwise, the compiler does not know the bool type.