bitset - STL C++

operator&()

Declaration

bitset<N> operator&(const bitset<N>&, const bitset<N>&);

Description

This is the overloaded bitwise and operator for bitsets.

Header Include

#include <bitset>

Example

#include <bitset>
#include <iostream>

int main()
{
	using namespace std;

	// Create two bitsets of four bits
	bitset<4> qBits1(6);
	bitset<4> qBits2(3);
	cout << "bitset<4> #1 : "<< qBits1 << endl;
	cout << "bitset<4> #2 : "<< qBits2 << endl;

	// Perform a bitwise and
	bitset<4> qBitsAnd = (qBits1 & qBits2);
	cout << "The bitwise and is " << qBitsAnd << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

operator&() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.