Sign in to follow this  
recon6

Keep on getting error with class

Recommended Posts

recon6    112
Hi. I'm using SDL in codeblocks with the SDL-gfxprimitives library. I'm trying to build a class that creates that creates a few different circles. This is the header file code. #include <SDL/SDL.h> #include <SDL/SDL_gfxprimitives.h> class Object { public: int createShip(SDL_Surface* dest,int x, int y, int radius,Uint8 r,Uint8 g,Uint8 b, Uint8 a); }; int Object:: createShip(SDL_Surface* dest,int x, int y, int radius,Uint8 r,Uint8 g,Uint8 b, Uint8 a) { int filledCircleRGBA( dest, x, y, radius, r, g, b, a); } This is how i'm trying to use it in my main function. Object ship; ship.createShip(screen,xpos,ypos,10,150,255,0,255); Where xpos,ypos and r are defined. I keep on gettin the error message: error: initializer expression list treated as compound expression. How can i fix this? Thanks.

Share this post


Link to post
Share on other sites
Aardvajk    13205
You should also either return an int value from your createShip() method, or change its signature to return void if no return value is required.

You may only be getting a warning about this from the compiler at the moment, but if you later accidentally use the return value somewhere else, you will be using a garbage value.


If filledCircleRGBA() returns an int, you maybe want:


int Object:: createShip(SDL_Surface* dest,int x, int y, int radius,Uint8 r,Uint8 g,Uint8 b, Uint8 a)
{
return filledCircleRGBA( dest, x, y, radius, r, g, b, a);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this