Instantiate a bitset object for holding 4 bits, all initialized to '0000' : bitset « bitset « C++ Tutorial






#include <bitset>
#include <iostream>
#include <string>

int main ()
{
    using namespace std;

    bitset <4> fourBits;
    cout << fourBits << endl;

    return 0;
}








18.1.bitset
18.1.1.Initialize a bitset with hex number
18.1.2.A bitset to hold 8-bits
18.1.3.Read a binary number into a bitset
18.1.4.Test value in a bitset
18.1.5.Create a copy of a bitset
18.1.6.Reset bit in a bitset
18.1.7.instantiate a bitset object for 8 bits, given an unsigned long init value
18.1.8.Instantiate a bitset object for holding 5 bits, initialize it to a bit sequence supplied by a string
18.1.9.Instantiate a bitset object for holding 4 bits, all initialized to '0000'
18.1.10.write a decimal integer as a binary number
18.1.11.Use bitset with enum together