Purchase Solution

Unions in C++

Not what you're looking for?

Ask Custom Question

1) Define a C++ union. Explain how a union may be used.
2) How may sharing be associated with unions?
3) What are the alternatives to unions?

Purchase this Solution

Solution Summary

Solution gives enough examples to illustrate the concepts explained therein.

Solution Preview

1) Define a union. Explain how a union may be used.

Briefly we can define union as a user defined data type that can be used to manipulate same memory space as different data type entities. In other words, union is a user defined data type that allows same portion of memory to be accessed as different data types, as all of the union members share same location in memory.

Consider a union of an int, a float and a char array of size 4 units.

union cfi {
char ca[4];
float f;
int i;
} var;

We can access different members of this union as shown ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Networking Questions

This quiz consists of some basic networking questions.