If the number of bits are fixed at compile time, you would be much better off using std::bitset
If not, (i.e. number of bits varies at runtime), then you should see and can use boost::dynamic_bitset)
In both of these, it is extremely easy to do all the bitwise operations.