Check the following code snippet
struct st
{
struct st
{
int a ;
int b ;
} st;
int a1 ;
} ;
struct st obj ;
struct st obj1 ;
int main()
{
return obj.a1 + obj1.b ;
}
Microsoft's compiler Visual Studio 6.0 compiles the program succesfully. I am confused with the use of 'struct st'. What is the size of obj and obj1?
GCC gives
error: nested redefinition of ‘struct st’
error: ‘struct st’ has no member named ‘a1’
If VC6 compiles this, that's fine, but this is invalid.
If you want to know the size of obj, that's sizeof obj. I'd assume VC6 just flattened out the structure and assigned it three ints.
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