简体   繁体   中英

what's the meaning of *&

I am a java coder and not familar with the c++ language. But right now,i read the following code:

void method(A* a,A*& b);

A *a;
A *b;
method(a,b);

And my question is: what's the meaning of "*&"?Does it means that it represent the value of b itself? thx

b is a reference to a pointer of A .

So if method sets b , the b in scope of the call will be changed.

Read it from right to left. A*& b says that b is a reference to an object that points to an A . Why is this useful? It allows you to directly modify the pointer that is being passed into the function. Whatever happens to b inside that function will be visible when the function returns.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM