-4

Possible Duplicate:
Reference to a pointer

I'm going through some code, and see Foo*& bar. How is that to be interpreted? Thanks!

Community
  • 1
  • 1
Adam_G
  • 7,156
  • 18
  • 76
  • 136

5 Answers5

2

bar is a reference to a pointer to Foo.

Alexey Frunze
  • 59,618
  • 10
  • 77
  • 173
2

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;
}
juanchopanza
  • 216,937
  • 30
  • 383
  • 461
1

Read right to left:

Foo*& bar

[bar] is a [reference] to a [pointer] to a [Foo]
Sebastian Mach
  • 37,451
  • 6
  • 88
  • 128
1

It's usually helpful to read such declarations right-to-left:

Foo*& bar;
  • bar
  • is a reference &
  • to a pointer *
  • to a Foo
Anders Johansson
  • 3,836
  • 17
  • 18
0

A reference, to a pointer, to a Foo.
Probably used as a function parameter?
Possibly an "out parameter".

Grimm The Opiner
  • 1,748
  • 11
  • 29