-4

I have two function signatures in C++

void printArray(int* arrayPtr);
void printArray(int*& arrayPtr);

I understand the 1st function. It says the function takes in a arrayPtr argument which is of type that's a pointer pointing to an integer.

Both function signature works, but I have a hard time understanding the 2nd signature(*&) and what benefits it offers?

WABBIT0111
  • 2,233
  • 2
  • 18
  • 30

1 Answers1

2

It's exactly the same as type versus type&; the first is a value and the second is a reference. The fact that type is a pointer doesn't change that.

Pete Becker
  • 74,985
  • 8
  • 76
  • 165