Reading pointers finally make sense and I just want to share and be told off if I'm wrong. It's all down to the names and the equals sign!
So,& gives the reference,
* is the dereference.
These are inverse operators so applying both is like doing nothing. A lot like multiply by 2 and divide by 2 or add two and subtract 2. More formally, a/a = 1 and 1 + a - a = 1. So following on *& = 1.
Consider the snippet from Cprogramming.com pointers,
Code:
int x; // A normal integer
int *p; // An pointer to an integer
p = &x; // Assign the address of value x to p
cin >> x; // Give x a value
cin.ignore(); // Remove the carriage return from the entry
cout << *p << "\n"; // This will print the value entered for x
Now the bit that clicked for me was this,
so if I apply the * operator, I must apply to both sides
but the operators are inverses on the right hand side
the last line would act like and it does.
Hopefully someone more practiced can say if this is a good schematic view. I've not seen this mentioned elsewhere and hope it helps someone who is stuck with pointers but thinks like a mathematician, got to be one or two out there.