Unions - overview

Nasza ocena:

3
Wyświetleń: 784
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Unions  - overview - strona 1 Unions  - overview - strona 2

Fragment notatki:

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)

Zaloguj się, aby dodać komentarz