Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gf11speed

Defining Arrays in Constructors?

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

How can I define an array inside a constructor? Say i have: struct STRUCTURE { int var[10]; STRUCTURE() { // how to define here? } }; I tried using a FOR loop to do it, but i didn''t seem to work. What else can I do? Thanks! *====================* http://www.syntasoft.com *=======================*

Share this post


Link to post
Share on other sites
Advertisement
The for-loop is the only thing that would make sense (for different values). If you all want identical values, such as 0, you might use memset.

Share this post


Link to post
Share on other sites
Hmm... for some reason when I use the FOR loop it doesn't work. I have no idea why. I haven't tried memset yet though. I do something like this:


typedef struct STRUCTURE
{
int iLookForPass[MAX_PLAY_ADJUSTMENTS];

STRUCTURE()
{

for(int a=0; a iLookForPass[ a ] = UNDEFINED;
}

}

};




[edited by - Gf11speed on February 1, 2003 3:22:58 AM]

Share this post


Link to post
Share on other sites
I got it... the problem was not in the code, but the fact that I kept loading the previous struct from disk where it wasn''t initialized properly. Oops!

Thanks for the help guys...

Share this post


Link to post
Share on other sites

  • 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!