Search code examples
c++bitsets

How to assign bitset value from a string after initializaion


I know it is possible to initialize bitsets using an integer or a string of 0s and 1s as below:

bitset<8> myByte (string("01011000")); // initialize from string

Is there anyway to change value of a bitset using an string as above after initialization?


Solution

  • Something like

    myByte = bitset<8>(string("01111001"));
    

    should do the trick.