Can a bool variable store more than 0x01?

后端 未结 6 1130
慢半拍i
慢半拍i 2021-01-21 09:48
#include 
#include 

using namespace std;

int main()
{
    bool a = 0x03;
    bitset<8> x(a);
    cout<

        
6条回答
  •  逝去的感伤
    2021-01-21 10:23

    bool a = 0x03; converts 0x03 to a boolean value. Since every numeric value that is not zero will be evaluated to be true, you'll see the first result, regardless of which data you'll assign.

提交回复
热议问题