[SDL] Question about arrays...

Lilith Calbridge lilith at dcccd.edu
Fri Feb 9 11:04:25 PST 2007


I believe the only time you can initialize an array like that is at the
time you're declaring it.  Otherwise, you have to address each element
individually.  That's in straight C/C++.  If the array is a class member
I'm not sure you can even do that.  The only way I could see that being
done at declaration time is if the array was a static member of the
class.  But you may not want that for this particular class.

-- 
Lilith

>>> On 2/9/2007 at 12:59 PM, <SlntHero at aol.com> wrote:
> Question about arrays...
>  
>  
> Hi,
>  
> I have a C++ Class with the following:
> Int8 Playfield[3][3];
>  
> Later in my program I wish to initialize the above 2 dimensional
array with  
> 
> the following values:
> 0 / 1 / 0
> 1 / 1 / 1
> 0 / 1 / 0
>  
> I tried the following, but it does not compile:
>  
> Playfield
> = { 0, 1, 0,
>      1, 1, 1,
>      0, 1, 1 };
>  
> Can someone tell me how to do the above correctly?
>  
> Thanks in advance!
>  
>  
> Jesse
> _SLNTHERO at AOL.com_ (mailto:SLNTHERO at AOL.com) 
> _http://www.SilentHeroProductions.com_ 
> (http://www.SilentHeroProductions.com) 
>  


More information about the SDL mailing list