I'm trying to do things with classes, but the tutorials don't seem to cover this. I have a header file that handles user input. In the user input, when space is pressed I create a new member of the class and increment the integer "ballamount" by one. I also call the ball[ballamount].ballinit(); function. So this creates a new ball and sets some variables. Now, in my main loop, I want to call the ballmove() and ballshow() functions in a for loop.
It looks like that. The code in user input looks like this:Code:for(int i = 1; i <= balls; i++){ ball[balls].ballmove(); ball[balls].ballshow(); }
This returns errors:Code:if(usrinput.key.keysym.sym == SDLK_SPACE) { //If Space is pressed balls++; //Add a ball ball ball[balls]; ball[balls].ballinit(); }
for the highlighted lines in the main loop. So I have no idea how I should go about this. Thanks for any help.Code:/home/craig/programming/particles/main.cpp|26|error: expected unqualified-id before ‘[’ token|

Register
Events
Popular
More
Post #1









