2 ms·
No, it's not the same. X a = new X("foo"); X b = new X("bar"); X c = a; swap(a, b); // after this, a points to X("bar") and b points to
by shiro 12y ago
No, it's not the same.
X a = new X("foo");
X b = new X("bar");
X c = a;
swap(a, b);
// after this, a points to X("bar") and b points to
// X("foo"), but c should remain pointing to X("foo").
If you swap the contents of the object, c would point to X("bar").