Sign in to follow this  

Keep on getting error with class

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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