To tylko jedna z 2 stron tej notatki. Zaloguj się aby zobaczyć ten dokument.
Zobacz
całą notatkę
Unions • A union - holds objects of different types and sizes(at different times) • May be used to save memory • The compiler takes care about alignment of objects in memory • Syntax: similar to structures union u_tag { int ival; float fval; char *sval; } u; • u will be large enough to hold the largest of the three types • The specific size is implementation-dependent • Any of these types may be assigned to u • The type retrieved must be the type most recently stored (really!) • The results are implementation-dependent if something is stored as one type and extracted as another • It is the programmer's responsibility to keep track of which type is currently stored in a union
... zobacz całą notatkę
Komentarze użytkowników (0)