Create a copy of a bitset : bitset « bitset « C++ Tutorial






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

int main ()
{
    using namespace std;

    // A bitset to hold 8-bits
    bitset <8> eightBits;
    cout << "Enter a 8-bit sequence: ";

    // Store user-supplied sequence into the bitset
    cin >> eightBits;
    cout << endl;

    // create a copy
    bitset <8> flipInput (eightBits);

    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