C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers


10,705 users

How can you reseat a reference to make it refer to a different object?

0 votes
asked May 28, 2011 by anonymous

1 Answer

0 votes
No. You can't separate the reference from the referent.

Unlike a pointer, once a reference is bound to an object, it can not be "reseated" to another object. The reference itself isn't an object (it has no identity; taking the address of a reference gives you the address of the referent; remember: the reference is its referent).

In that sense, a reference is similar to a const pointer such as int* const p (as opposed to a pointer to const such as const int* p). In spite of the gross similarity, please don't confuse references with pointers; they're not at all the same.
answered May 28, 2011 by daniel Advisor (5,600 points)

Related questions

0 votes
1 answer 213 views
0 votes
1 answer 54 views
54 views asked May 28, 2011 by anonymous
0 votes
1 answer 41 views
41 views asked May 28, 2011 by anonymous
+1 vote
1 answer 40 views