Array of Referances

Started by
1 comment, last by Zahlman 19 years, 3 months ago
Can I make a referance to an array. My compiler gave me an error. it looked a little bit like this:

int func( int &array[] );

int main()
{
  int test[10];
  func( test );
  return 0;
}

int func( &array[] )
{
  return 0;
}
"Are you threatening me, Master Jedi?" - Chancellor Palpatine
Advertisement
This "error" your compiler gave you, I presume it had a message and an error? Did you look them up?

In any case, your code is wrong. Arrays are passed by pointer, so what you have is a pointer to a reference. But references are not user-accessible indirection, so you can't obtain the address of the reference. Given that references are the same size as pointers, there's no "performance benefit" to be obtained in what you're trying to do, either.
Also, a reference to an array is not the same thing as an array of references (as in your thread title), which suggests you may be rather confused about what it is you are after...

This topic is closed to new replies.

Advertisement