Home > Articles > Programming > C/C++

Construction Unions: A C++ Challenge

In this C++ Challenge, Herb Sutter throws down the gauntlet. Can you get around the C++ rule of using constructed objects as members of unions? Find out the answer in this sample chapter.
This chapter is from the book

No, this Item isn't about organizing carpenters and bricklayers. Rather, it's about deciding between what's cool and what's uncool, good motivations gone astray, and the consequences of subversive activities carried on under the covers. It's about getting around the C++ rule of using constructed objects as members of unions.

JG Questions

  1. What are unions, and what purpose do they serve?

  2. What kinds of types cannot be used as members of unions? Why do these limitations exist? Explain.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.