03-04-2005, 08:12 PM
The thing is useful, among other things, and as mentioned, to save memory. It is used for example in the structure which is used to give attributes to a grammar using flex/bison, when symbols can have information attached. As this information can be of different types, you could have used a normal type structure, but that wastes memory as only one field would be used. Using a union, you get the same functionality but you take only the memory which is needed to store the biggest element.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i