Anonymous Unions

Anonymous Unions - though they were members of the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Anonymous Unions Here's a simple one. In C++ this usage is legal: struct A { union { int x; double y; char* z; }; }; whereas in C you'd have to say: struct A { union { int x; double y; char* z; } u; }; giving the union a name. With the C++ approach, you can treat the union members as
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: though they were members of the enclosing struct. Of course, the members still belong to the union, meaning that they share memory space and only one is active at a given time....
View Full Document

This note was uploaded on 02/27/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University.

Ask a homework question - tutors are online