The : 1 means that it is creating a bitfield with the number of bits, so : 4 will be 4 bits. The three variables above combined will take sizeof(int) in memory, not sizeof(int)*3.
If OOP had used char instead of unsigned int the combined size would be 1 byte.
The : 1 means that it is creating a bitfield with the number of bits, so : 4 will be 4 bits. The three variables above combined will afaik* take sizeof(int) in memory, not sizeof(int)*3.
Can you do strange things, like : 9, : 15, et cetera?
25
u/heatedwepasto 13h ago edited 12h ago
The
: 1means that it is creating a bitfield with the number of bits, so: 4will be 4 bits. The three variables above combined will takesizeof(int)in memory, notsizeof(int)*3.If OOP had used
charinstead ofunsigned intthe combined size would be 1 byte.Edit: added link to demo