C++ references: evaluate two claims Once a reference variable has been defined to refer to a particular variable it can refer to any other variable. A reference is not a constant pointer. Choose the single best option.

Difficulty: Easy

Correct Answer: Only 2 is correct.

Explanation:


Introduction / Context:
This question checks precise understanding of C++ references versus pointers. A reference acts as an alias to an existing object and is subject to strict binding rules. Many beginners mistakenly equate references with “constant pointers,” which leads to confusion about reseating, nullability, and dereferencing syntax.


Given Data / Assumptions:

  • Statement 1: After binding a reference to one variable, it can later refer to another variable.
  • Statement 2: A reference is not a constant pointer.
  • We consider standard C++ semantics without compiler extensions.


Concept / Approach:

A reference must be initialized to a valid object at its point of declaration and cannot be reseated to name a different object afterward. That is why references are often considered “aliases.” While some teaching materials loosely compare a reference to a “const pointer,” this is only an analogy and not a type identity. Pointers are objects with their own address and can be reassigned; references are not objects on their own and participate directly in expressions as the referred-to entity. Hence, it is more accurate to state “a reference is not a constant pointer.”


Step-by-Step Solution:

Check statement 1: false, because a reference cannot be reseated after initialization. Check statement 2: true, because references are not pointers (neither constant nor non-constant); they are aliases with different language rules. Conclusion: only statement 2 holds.


Verification / Alternative check:

Consider int x = 5; int& r = x; int y = 9; Attempting r = y; assigns to x through the reference; it does not reseat r. Taking &r yields the address of x, not a separate “reference object,” reinforcing that a reference is not a pointer variable.


Why Other Options Are Wrong:

Only 1 is correct — wrong; reseating is not permitted.

Both correct — wrong because statement 1 fails.

Both incorrect — wrong because statement 2 is accurate.


Common Pitfalls:

  • Confusing assignment through a reference with reseating the reference.
  • Thinking references can be null or re-bound like pointers.


Final Answer:

Only 2 is correct.

More Questions from References

Discussion & Comments

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