Function parameter question
Jan 8, 2014 at 7:41pm
I was doing some more tutorials and i found this function declaration (inside of a class):
|
void render( int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE );
|
yet when the function is called it only gives 2 values
|
classObject.render( ( SCREEN_WIDTH - gStartPromptTexture.getWidth() ) / 2, 0 );
|
I noticed that only the 2 ints the parameter asks for (
int x, int y
) are undeclared, the rest are declared to 0 or null or so on. so my question is:
When calling a function, you only need to pass the parameter values that are undeclared?
Jan 8, 2014 at 8:00pm
In your example above,
clip,
angle,
center, and
flip are called
default parameters, since they have default values provided for them.
If you don't provide a value for them, the compiler will use those default values.
Also see
http://www.cplusplus.com/doc/tutorial/functions/ (scroll down to "Default values in parameters").
Jan 8, 2014 at 8:12pm
Read that page and somehow managed to miss that part, exactly answers my question though, thanks ^^
Topic archived. No new replies allowed.