Test items:
1. arithmetic operation of four bool Variables
2. Memory size of the bool variable
Test code:
[Cpp]
1. # include <iostream>
2.
3. using namespace std;
4.
5. int main ()
6 .{
7. int iSizeCouner = 0;
8. bool bTestBool = false;
9. bool a = 3;
10. bool B = 1;
11. bool c = a + B;
12. bool d = a-B;
13.
14. // test
15. cout <"a =" <a <endl;
16. cout <"B =" <B <endl;
17. cout <"c =" <c <endl;
18. cout <"d =" <d <endl;
19.
20. iSizeCouner = sizeof (bTestBool );
21.
22. cout <iSizeCouner <endl;
23. cout <bTestBool <endl;
24. cout <bTestBool <endl;
25.
26. bTestBool = true;
27. cout <boolalpha <bTestBool <endl;
28.
29. while (1 );
30 .}
Print Output:
A = 1
B = 1
C = 1
D = 0
ISizeCouner = 1
BTestBool = 0
Conclusion:
1. In the four arithmetic operations, 0 and 1 are always involved in the calculation.
2. the bool variable occupies 1 byte.
From DriverMonkey's column