c++ - Bit field memory -


if declare this

struct s{   unsigned int bit:4; } 

how working?

  1. 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.
  2. 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

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -