Possible Duplicate:
Size of struct with a single element
Given any type A
and the following struct:
struct S
{
A a;
};
Are there any cases where sizeof(S)
is greater than sizeof(A)
?
For example, can sizeof(std::array<T, n>)
be greater than sizeof(T[n])
?
Being able to use A inside of S means that the compiler already has knowledge of the structure of A and has already added padding bytes to it. I see no reason for it to add further padding to S, as it already is aligned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With