C++ Bitset Library - reset() Function



Description

The C++ function std::bitset::reset() reset single bit of bitset to zero.

Declaration

Following is the declaration for std::bitset::reset() function form std::bitset header.

C++98

 bitset& reset (size_t pos); 

C++11

 bitset& reset (size_t pos); 

Parameters

pos − Position of the bit whose value is reset.

Return value

Returns this pointer.

Exceptions

Throws out_of_range exception if pos is greater than or equal to bitset size.

Example

The following example shows the usage of std::bitset::reset() function.

 #include <iostream> #include <bitset> using namespace std; int main(void) { bitset<4> b("1111"); cout << "Before reset operation b = " << b << endl; b.reset(0); cout << "After reset operation b = " << b << endl; return 0; } 

Let us compile and run the above program, this will produce the following result −

 Before reset operation b = 1111 After reset operation b = 1110 
bitset.htm
Advertisements