Possible Duplicate:
Reference to a pointer
I'm going through some code, and see Foo*& bar
. How is that to be interpreted? Thanks!
Possible Duplicate:
Reference to a pointer
I'm going through some code, and see Foo*& bar
. How is that to be interpreted? Thanks!
It is a reference to a pointer to Foo
. the usual use-case is when you want a function to change a pointer passed to it as an argument:
void foo(Foo*& bar)
{
bar = something_else;
}
Read right to left:
Foo*& bar
[bar] is a [reference] to a [pointer] to a [Foo]
It's usually helpful to read such declarations right-to-left:
Foo*& bar;
bar
&
*
Foo
A reference, to a pointer, to a Foo.
Probably used as a function parameter?
Possibly an "out parameter".