Defining Arrays in Constructors?

Started by
3 comments, last by Gf11speed 21 years, 2 months ago
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 *=======================*
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
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.

Kippesoep
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]
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
what doesn''t work in it? how is it broken?
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...
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)

This topic is closed to new replies.

Advertisement