DWORD or bool*
I want to store 26 bits, one for each letter in the alphabet that I want to be true or false. I would store this in a boolean-array like this:
but I noticed that some functions (like GetLogicalDrives()) use a DWORD to store the 26 bits in. I'd say that for stuff like this a boolean-array would be way easier because you don't have to use any bit-comparison. So.. why is a DWORD used instead of a boolean-array, and should I use a DWORD for situations like this too?
If datasize and speed don't matter, i should use the array version. DWORD bit..........ing is probably faster.
I always do it the DWORD way, why use 26 bools when one int can do it?
May be hard to [understand|work with] at the beginning, but once you get used to it, you'll like it.
#define IsBitSet(val, bit) (((val) & (1 << (bit))) ? true : false)
// or for type safety
inline bool IsBitSet(const integer_t &val, const size_t &bit)
return (val & (1 << bit)) ? true : false;