Jump to content
  • Advertisement
Sign in to follow this  
chaosgame

Array of Referances

This topic is 4930 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!