I have seen this type declaration. Can someone explain me this
I slightly modified the variable names. I am confused and don't understand the Buf. Please advise.Code:typedef unsigned int uint16; typedef uint16 Buf[32][8]; Buf buf1;
I have seen this type declaration. Can someone explain me this
I slightly modified the variable names. I am confused and don't understand the Buf. Please advise.Code:typedef unsigned int uint16; typedef uint16 Buf[32][8]; Buf buf1;
Seems to me to be just automatic stack arrays, for example
takes the last element of the last array in variable a and copies it to the first element of the first array in variable bCode:Buf a, b; a[31][7] = b[0][0];
@awwdert....I think that's actually copying the first element of the first array in b to the last element of the last array in a, but otherwise you're on point.
I'm not sure what's "new" about this....is the ability to subscript the typedef a recent addition to the language?
Whoops, Me dumb XP, anyway I think xey meant new as in new to xem
It might be helpful to understand typedefs the way the standard sees them: a typedef is a declaration of identifiers that has the storage class specifier of typedef. So you should ask yourself, what does this declaration declare without the storage class specifier? That is, in this case, consider:Originally Posted by Cleaner123
The answer of course is that Buf is an array of 32 arrays of 8 uint16 objects. Now consider the typedef storage class specifier, and Buf becomes the type of Buf without the typedef specifier, i.e., Buf is an alias of the type "array of 32 arrays of 8 uint16 objects". Hence, since Buf is used to declare buf1, buf1 is an array of 32 arrays of 16 uint16 objects.Code:uint16 Buf[32][8];
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)