I was supposed to answer the question and take a note here.
The *&l is a reference to a pointer, and the argument is a pointer. So L is the alias of the argument pointer, and the modification of the alias L is equal to the modification of the argument.
*l is a pass value, you cannot change the value of the argument pointer variable passed in.
Program code:
#include <iostream>
using namespace Std;
void foo (int*p);
int main ()
{
int a=5;
int *b=&a;
printf ("%d%d\n", b,*b);
Foo (b);
printf ("%d%d", b,*b);
}
void foo (int* p)
{
*p=*p+1;
p=p+1;
}
Output to
Can be seen as pointer B has not changed, pointer b saved value changed
Program code:
#include <iostream>
using namespace Std;
void foo (int*&p);
int main ()
{
int a=5;
int *b=&a;
printf ("%d%d\n", b,*b);
Foo (b);
printf ("%d%d", b,*b);
}
void foo (int*& p)
{
*p=*p+1;
p=p+1;
}
The values saved by pointer B and pointer b are changed.
The following is a copy.
This technique is used for example to define a function that safely removes pointers, so to say, security is to delete the pointer only when it is zero, and then assign the pointer to null immediately after the deletion.
Template<typename t>
Inline Safe_delete (t*& ptr)
{
if (PTR)
{
Delete ptr;
ptr = NULL;
}
}
I use QT and vs both to find that the defined pointers are such security pointers.
The pointer is not zero and is not allowed to be deleted. deleted, if not again null.
C + + pointers and reference issues