|
1.Passed a reference to int&a;
The first sentence in the function is int * p =&a;
After that, all operations are performed on p, so there is no difference from passing pointers.
2.Pass a pointer int * p;
The first sentence in the function is int&a = * p;
After that, all operations are performed on a, so there is no difference from passing by reference.
3.If you say
int * p = NULL;
int * p = (int *) 1;
Is dangerous
4, then
int&a = * ((int *) 0);
int&a = * ((int *) 1);
Also dangerous
In favor ofverance, I personally feel that pointers and references have no essential difference except for writing. |
|