Someone on the Internet said that bool is more efficient than bool. I don't understand, so I checked it online. Now I will summarize it. I don't know if it is correct.
-------------------------------------------------------------------------------
First, write in VCCodeTest the size of these two types. The Code is as follows:
Cstring temp;
Temp. Format ("% d", sizeof (bool ));
Trace ("/R/n ---------------------/R/N ");
Trace ("in VC ++ bool's size is :");
Trace (temp );
Trace ("/R/n ---------------------/R/N ");
Temp. Format ("% d", sizeof (bool ));
Trace ("/R/n ---------------------/R/N ");
Trace ("in VC ++ bool's size is :");
Trace (temp );
Trace ("/R/n ---------------------/R/N ");
The running result is as follows:
-----------------------
In VC ++ bool's size is: 1
-----------------------
-----------------------
In VC ++ bool's size is: 4
-----------------------
bool occupies 4 bytes and bool occupies 1 byte.
I thought the computer would process 1 byte faster than 4 bytes. In fact, from time to time.
because the current CPU is 32-bit, the CPU processes 4 bytes at a time, so processing 1 byte requires additional processing.
therefore, the efficiency is low.
typedef char bool
typedef DWORD bool