Possible Duplicate:
Why are references not reseatable in C++
I am trying to more or less swap two reference variables (as practice, I could have swapped the actual variables). I tried doing this by making a temporary variable and making one of the references equal the other, but this got shot down by the compiler. Here is an example:
void Foo()
{
//code
int& ref1 = a;
int& ref2 = b;
int temp;
temp = ref1;
ref1 = ref2;
ref2 = temp;
//or, better yet
std::swap(ref1, ref2);
}
I got an error, and looked on the faq lite. It details that they cannot be reseated, but does not explain why. Why?
Here is a link to the Faq Lite for reference (<---, get it?).