bitset - STL C++

bitset<N>::set()

Declaration

bitset<N>& bitset<N>::set();

Description

This is the member function set() for the bitset class template. This function sets all of the bits in the bitset to 1. The overloaded version sets the bit at "qIndex" to the value given "bValue."

Header Include

#include <bitset>

Overloads

bitset<N>& bitset<N>::set(size_t qIndex, bool bValue = true);

Example

#include <bitset>
#include <iostream>

int main()
{
	using namespace std;

	// Create a bitset
	bitset<4> qBits(5);
	cout << "bitset<4> : " << qBits << endl;

	// Set all fo the bits to one
	qBits.set();
	cout << "bitset<4> : " << qBits << endl;

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

Output

bitset<N>::set() Output
 

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