Result of XOR between the two sequences : bitset and or « 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;

    // another 8-bit sequence to perform bitwise-ops against the first
    bitset <8> eightMoreBits;
    cout << "Enter another 8-bit sequence: ";
    cin >> eightMoreBits;
    cout << endl;

    cout << eightBits << " ^ " << eightMoreBits << " = "
                      << (eightBits ^ eightMoreBits)    // bitwise XOR
                      << endl;

    return 0;
}








18.3.bitset and or
18.3.1.Result of XOR between the two sequences
18.3.2.Result of OR between the two sequences
18.3.3.Bitset 'and', and shift operators
18.3.4.Result of AND between the two sequences
18.3.5.Or fields in bitset