Home Segments Index Top Previous Next

Chapter 29:

How To Use Unions
to Capture Class Distinctions

You have learned that C's attention to type requires all array elements to be of the same type. Accordingly, you might wonder what you can do when your problem is to deal with array elements that are inherently of mixed type.

In this chapter, you learn that C's union data type provides one solution to the mixed type problem. You should know, however, that other languages, such as C++, offer more elegant solutions.