-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,337
  • 20
  • 86
  • 148

5 Answers5

2

bar is a reference to a pointer to Foo.

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
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
  • 223,364
  • 34
  • 402
  • 480
1

Read right to left:

Foo*& bar

[bar] is a [reference] to a [pointer] to a [Foo]
Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130
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,926
  • 19
  • 19
0

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

Grimm The Opiner
  • 1,778
  • 11
  • 29