Check out example codes for "bitset c++". It will help you in understanding the concepts better.

Code Example 1

// constructing bitsets
#include <iostream>       // std::cout
#include <string>         // std::string
#include <bitset>         // std::bitset

int main ()
{
  std::bitset<16> foo;
  std::bitset<16> bar (0xfa2);
  std::bitset<16> baz (std::string("0101111001"));

  std::cout << "foo: " << foo << '\n';
  std::cout << "bar: " << bar << '\n';
  std::cout << "baz: " << baz << '\n';

  return 0;
}

Code Example 2

// C++ program to demonstrate that we can get part of a  
// bit string in bitset. 
#include <bitset> 
#include <string> 
#include <iostream> 
  
int main() 
{ 
  std::string bit_string = "110010"; 
  std::bitset<8> b1(bit_string);             // [0, 0, 1, 1, 0, 0, 1, 0] 
  
  // string from position 2 till end 
  std::bitset<8> b2(bit_string, 2);      // [0, 0, 0, 0, 0, 0, 1, 0] 
  
  // string from position 2 till next 3 positions 
  std::bitset<8> b3(bit_string, 2, 3);   // [0, 0, 0, 0, 0, 0, 0, 1] 
    
  std::cout << b1 << '\n' << b2 << '\n' << b3 << '\n'; 
  
  return 0; 
} 

Learn ReactJs, React Native from akashmittal.com