bitset - STL C++

bitset<N>::reference::flip()

Declaration

bitset<N>::reference& bitset<N>::reference::flip();

Description

This is the flip() member function for the class reference that is a nested class inside the bitset class template. This function is used to flip the single bit of a bitset which the reference designates.

Header Include

#include <bitset>

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> before flip : "<< qBits << endl;

	// Flip the bit at index 3--start at 0 on the right
	qBits[3].flip();
	cout << "bitset<4> after flip  : "<< qBits << endl;

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

Output

bitset<N>::reference::flip() Output
 

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