I wonder if the following construction is possible:
typedef std::bitset<4> BIT4;
BIT4* x=new BIT4[3];
BIT4* y=new BIT4[5];
My concerns are:
(1) is the array of BIT4 a legal construction?
(2) if yes, how the pointer will address these arrays of size 3 and 5? last element of these arrays seems to take 1/2 byte, is another half just lost and we start the next array from a new byte or how does it work?
Thank you for your help!
What you are trying to do as I understand is
use 12 bits for 3 elements in an array called x
use 20 bits for 5 elements in an array called y
This is wrong as you will end up using:
if you want to achieve what you want you need to do it like this:
and you can of course allocate it dynamically if you want to.