Sign in to follow this  

Array of Referances

This topic is 4718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

This topic is 4718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this