for inside class

Started by
2 comments, last by lordcorm 17 years, 8 months ago
I was wondering if the following code would do what i wanted it to...
Quote: class Character(); { private: SDL_Rect clip[19]; for i = 0 To 19 { clip.x = 16*i; clip.y = 32*i; clip.w = 16; clip.h = 32; }
This is meant to create clip[0 to 19] with the correct variables for each clip. Also does this automatically initialize inside a class?
Advertisement
Assuming this is C++, you'll need to put the for loop inside the constructor for the class. Ex:
class Character {  private:    SDL_Rect clip[19];  public:    Character() {      for (i = 0; i < 19; i++) {        clip.x = 16*i;        clip.y = 32*i;        clip.w = 16;        clip.h = 32;      }    }};
i see... thanks, i'll do it like that :)
you shouldnt be doing SDL untill you know C++ i had to learn that the hard way :D ;)

This topic is closed to new replies.

Advertisement