Jump to content
  • Advertisement
Sign in to follow this  
Kest

Fixed sized array reference as a parameter

This topic is 3926 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

Just a very simple question. I'm not sure if I'm messing up the syntax, or if it's just impossible. I'll just lay it out:
void Func(const int &list[10])
{
...
}

int list[10];
Func( list );
Apparently, this is an array of references, which is illegal. I know I can pass by const pointer or by const pointer reference, but I would like the fixed size (10 here) to be an obvious restraint. Both inside the function and for its callers. Thanks for any information.

Share this post


Link to post
Share on other sites
Advertisement
Or you could use boost::array:


void Func(const boost::array<int, 10> &list);



You'd also get the other benefits it provides.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!