0
How many bit(s) does a boolean variable contain? I remember it's 1. Correct me if I'm wrong...
3 Answers
+ 2
As a boolean variable contains either a "0" or "1", it is easily stored in a single bit but the smallest unit to store any value in computer is 1 Byte(=8 bits). So, it's 1 byte, not 1 bit.
+ 1
Ou no, the boolean variable does not contain one bit. Because the compiller cant adress or divide single bites in byte for variable. So, the sizes of any variables must be in whole bytes. How many bytes for boolean it depends of different compilators C++. Look in theirs specific dcumentations, or use a sizeof operator.
Of course, when yu want to use only one bit for save some boolean value , you have to coding it yourselves, with the bit logic operators upon byte..
0
So... Learn C++, Data Types, the operator sizeof(), wrong descriptive image...