So interviewer says "I want you to write out a short function to read in 1 byte and put out how many bits are in it". Thoroughly confused I ask him to repeat. "I want it to read in 1 byte, and pull out each bit individually". I had to claim ignorance at this point.
This was yesterday in a long interview, so it's not verbatim - but pretty close
In C++, a byte is a char. As for how many bits are in it; that's system dependent. Fortunately, if you've got a conformant implementation, you can use the climits header to know how many bits there are in the byte, and then you can determine the value of each bit (one or zero) by bit-masking or bitshifting or whatever your preferred method is.
thx Moschops
I got that he was alluding to a char, but as for reading the individual bits, I never even considered that was something that anyone would want to do.
It's quite common in C++; I see it a lot in flag bitsets indicating the status of objects. For example, checking the state of a stream. You've probably set flags and read flags without realising it.
Interviewers often know less about the language than you do -- they go wandering in with a list of questions to (mis-)ask.
The interviewer was probably trying to ask for a function that calculates the number of set bits in a byte. This is a very old problem, with quite a number of well-known solutions.