bitset - STL C++

bitset<N>::reference::operator=()

Declaration

reference& bitset<N>::reference::operator=(const reference& kqrRef);

Description

This is the operator=() member function for the class reference that is a nested class inside the bitset class template. This function takes a reference ("kqrRef") or bool ("bBool") argument and returns the bit of the bitset designated by the reference, which is then used to set the value of the reference on the left-hand side.

Header Include

#include <bitset>

Overloads

reference& bitset<N>::reference::operator=(bool bBool);

Example

#include <bitset>
#include <iostream>

int main()
{
	using namespace std;

	// Create a bitset of four bits with the 2nd one "on"
	bitset<4> qBits(2);
	cout << "bitset<4> : "<< qBits << endl;

	// Set the fourth bit equal to the second
	qBits[3] = qBits[1];
	cout << "bitset<4> : "<< qBits << endl;

	// Set the third bit equal to true
	qBits[2] = true;
	cout << "bitset<4> : "<< qBits << endl;

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

Output

bitset<N>::reference::operator=() Output
 

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