How to iterate through a binary number in c++?
In the mentioned function I'm getting
invalid operands to binary conversion (bitset<8> and int)
This is the function in my code, which is getting the stated error
int value(int x)
{
    int temp=0,counter=0;
    bitset<8> i(x);
    while (i != 0) {
       temp = i % 10;
       if(temp == 1) {
           counter++;
       }
       i = i/10;
  }
  return counter;
}
 
     
    