Jump to content
  • Advertisement
Sign in to follow this  

Fixed sized array reference as a parameter

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

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!