Difficulty: Easy
Correct Answer: An array of references is not acceptable.
Explanation:
Introduction / Context:
Unlike pointers, C++ references must bind to an object at initialization and cannot be left unbound. This property affects whether you can create arrays of references and whether a reference can later “point” somewhere else. The question probes both ideas through multiple choices.
Given Data / Assumptions:
Concept / Approach:
Because references must be bound at initialization and have no “null” state, standard C++ does not allow arrays of references as first-class types. You can, however, have arrays of pointers or arrays of reference wrappers (e.g., std::reference_wrapper) that emulate reference semantics. Additionally, a reference cannot later refer to a different variable, so claims of reseating are false. The notion that a reference is “like a structure” is baseless; it is an aliasing mechanism, not an aggregate type.
Step-by-Step Solution:
Verification / Alternative check:
Attempt to declare int& a[3]; Most compilers emit an error. Using std::reference_wrapper<int> a[3]; is legal, illustrating the preferred pattern when reference-like arrays are required.
Why Other Options Are Wrong:
Array acceptable — contradicts the language rule.
Reseating a reference — violates reference semantics.
Like a structure — a reference is not an aggregate type.
Common Pitfalls:
Final Answer:
An array of references is not acceptable.
Discussion & Comments