The following code fails as expected because I am passing an invalid pointer:
Code:
void func2(char* c, char* d) {
   c = d;  
}

void func() {
   char* c = NULL;
   char* d = new char('f');
   func2(c, d);
   char e = *c;
   printf(e);
}

int main(int argc, const char* argv[])
{
	func();
}
But if I change func2 to...
Code:
void func2(char*& c, char* d) {
   c = d;  
}
... it works because I'm passing a reference to the pointer.

I don't really understand the mechanic that allows this to work. Since the pointer is invalid why does passing it as a reference make a difference?
Cheers.