Mastering C++: 2025 All-In-One Quiz – Ace 'Thinking in C++' with Comprehensive Practice!

Question: 1 / 565

What is NOT allowed for a union in C++?

Having member functions

Including constructors and destructors

Being used as a base class during inheritance

Unions in C++ are not allowed to be used as base classes during inheritance. This is because unions only store one variant of data at a time, which can lead to issues when using inheritance. It is possible for the derived class to end up with incorrect data types and values when inheriting from a union class. All other options are allowed for a union in C++, including member functions, constructors and destructors, and access control modifiers.

Get further explanation with Examzify DeepDiveBeta

Having access control modifiers

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy