C++ Bitset Library - reset() Function



Description

The C++ function std::bitset::reset() reset all bits of bitset to zero.

Declaration

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

C++98

 bitset& reset(); 

C++11

 bitset& reset() noexcept; 

Parameters

None

Return value

Returns this pointer.

Exceptions

This member function never throws exception.

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(); 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 = 0000 
bitset.htm
Advertisements