Which statement about C++ references is correct? Pick the most accurate description from the options provided.

Difficulty: Easy

Correct Answer: A reference is a constant pointer.

Explanation:


Introduction / Context:
In teaching, a common mental model is to think of a reference as if it were a constant pointer that is automatically dereferenced. While not literally true in the type system, this analogy helps explain binding and non-reseating behavior. This question asks you to choose the best fit among imperfect options.



Given Data / Assumptions:

  • References must be initialized and cannot be reseated.
  • They provide aliasing semantics and implicit dereference.
  • Other options propose constructs that are ill-formed (arrays of references, references to references).



Concept / Approach:
Among the answers, 'A reference is a constant pointer' is the closest analogy: like a const pointer to T (T *const), a reference always refers to the same object and does not require explicit dereference to access it. Options C and D are false in standard C++; option B contradicts the commonly accepted analogy and the semantics of binding.



Step-by-Step Solution:
1) Eliminate C and D based on language rules (both constructs are disallowed directly).2) Between A and B, choose the analogy that reflects non-reseating and automatic access.3) Select A as the best descriptive (didactic) fit.4) Clarify that this is an analogy, not strict type equivalence.



Verification / Alternative check:
Compare behavior: assigning through a reference changes the referent, akin to assigning through a const pointer to the same object.



Why Other Options Are Wrong:
B: rejects the useful and widely taught analogy.C: arrays of references are ill-formed.D: direct references to references are ill-formed; only template reference collapsing exists.



Common Pitfalls:
Taking the analogy as literal identity. In the type system, references are not pointers and have distinct rules (e.g., cannot be null by default).



Final Answer:
A reference is a constant pointer.


More Questions from References

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion