Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


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

  1. Having member functions

  2. Including constructors and destructors

  3. Being used as a base class during inheritance

  4. Having access control modifiers

The correct answer is: 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.