#include
#include
using namespace std;
int main()
{
bool a = 0x03;
bitset<8> x(a);
cout<
A bool
can only hold two values: false
and true
.
When/if used in an integer context, a bool
can be converted to an int
. In this case, false
converts to 0
and true
converts to 1
.
Regardless of the size of storage used for a bool
(e.g., sizeof(bool)==1
and sizeof(bool)==4
are both fairly common) it can still only hold the two values false
and true
, which always convert to 0
and 1
respectively. No other value is possible.