c++ - Bit field memory -
if declare this
struct s{ unsigned int bit:4; }
how working?
- i allocate 2 bytes in memory(size of structure(got size here http://en.cppreference.com/w/cpp/language/bit_field) use 4 bits of it, , other memory in structure wasted.
- i allocate 4 bits, nothing more.
i'm confused , can't find info anywhere.
when write
s s;
you allocate sizeof (s)
bytes, seems 2 in case.
fact use 4 bits of space not change size.
Comments
Post a Comment