Julie said:
Try again.
No *variable* is sharing the same address. Node, head, and tail all have
different addresses, unless you can say that any of the following is true:
&node == &head == &tail
It doesn't matter what node _points_ to, it matters where node _is_.
Under your logic, the following two variables:
int a = 1;
int b = 2;
become the _same_ same variable with the following:
b = 1;
Surely you don't now consider a and b the same _variable_, do you?
Remember, we are talking about _addresses_ of variables, not the _value_ of
variables.
<my two cents>
1. Technically, the discussion is about objects, identifiers that
designate/denote objects (aka variable names in C++), and values.
2. Julie is right, insofar as no two distinct identifiers can
designate the same object - with the obvious exception of union
members, but consider: union { int a, b; } u, *up = &u;
Now u.a, u.b, up->a and up->b denote the same object, but they are
*not* identifiers that denote objects, but expressions consisting
of two operands and one operator each. The member designators a
and b cannot be used in their own right to denote an object, they
can only appear as second operand of the . or -> operator.
3. The others are right, in that two pointer objects can reference the
same memory location (= have the same value, just like two ints
can hold equal values). This however has no bearing on the "swap a
variable with itself" issue: swapping the pointer values won't work
portably with XOR anyway, and using indirection to access the
pointed-to object involves an expression that is *not* a variable.
4. The infamous "swap with XOR" method has not only limitations WRT
the type of the operands [*], it's also broken by design, because
it fails to correctly swap the value of an object (sic!) with
itself.
5. I suggest to drop the term "variable" all together, *especially* in
cross-posts between c.l.c and c.l.c++, since it's not defined at
all in the C standard and IMHO somewhat vaguely defined in the C++
standard.
[*] Modulo accessing the representation of each operand byte-per-byte
through a pointers to unsigned char.
</my two (actually five ;-) cents>
Regards