C++ : why bool is 8 bits long?

Because every C++ data type must be addressable.

How would you create a pointer to a single bit? You can’t. But you can create a pointer to a byte. So a boolean in C++ is typically byte-sized. (It may be larger as well. That’s up to the implementation. The main thing is that it must be addressable, so no C++ datatype can be smaller than a byte)

Leave a Comment