Bool and bool
1. 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
2. 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 the result of # define, which is used to solve the environment difference between the program in C and C ++, the following values are false/true in windef. h definition:
# 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.
C ++ in Linux
The compiler must use g ++. Otherwise, the compiler does not know the bool type.
In short, the differences between big bool and small bool:
1. Different Types
Bool is int type
Bool is Boolean
2. Different Lengths
Bool has only one byte
The bool length depends on the actual environment. Generally, it can be regarded as 4 bytes.
3. Different values
Bool values: false and true, which are the difference between 0 and 1.
Bool values: false and true, which are the difference between 0 and non-0.