Reset bit in a bitset : bitset « bitset « C++ Tutorial






#include <bitset>
#include <iostream>

using namespace std;

int main( ){
   const int num_lights = 15;
   const bitset<num_lights> outside( 0xf );
   const bitset<num_lights> inside( 0xff0 );
   const bitset<num_lights> driveway( 0x7000 );

   bitset<num_lights> lights;

   for( int i = 0; i < num_lights; i +=2 )
      lights.reset( i );
   cout << lights;

}








18.1.bitset
18.1.1.Initialize a bitset with hex number
18.1.2.A bitset to hold 8-bits
18.1.3.Read a binary number into a bitset
18.1.4.Test value in a bitset
18.1.5.Create a copy of a bitset
18.1.6.Reset bit in a bitset
18.1.7.instantiate a bitset object for 8 bits, given an unsigned long init value
18.1.8.Instantiate a bitset object for holding 5 bits, initialize it to a bit sequence supplied by a string
18.1.9.Instantiate a bitset object for holding 4 bits, all initialized to '0000'
18.1.10.write a decimal integer as a binary number
18.1.11.Use bitset with enum together