Tuesday, September 9, 2008

Cisco CCNA Certifications Exam 640-802

Unions are similar 350-001 to structs, but they differ in one aspect: the fields of a union share the same position in memory. The size of the union is the size of its largest field (or larger if alignment so requires, for example on a SPARC machine a union contains a double and a char [17] so its size is likely to be 24 because it needs 64-bit alignment). Unions cannot have a 350-030 destructor.

What is the point of this? Unions provide multiple ways of viewing the same memory location, allowing for more efficient use of memory. Most of the uses of unions are covered by object-oriented features of C++, so it is more common in C. However, sometimes it is 640-802 convenient to avoid the formalities of object-oriented programming when performance is important or when one knows that the item in question will not be extended.

No comments: