You are here:

C++/default arguments


i have a question about default arguments in c++.
could you plz tell me what's the implication of"Default arguments must be the rightmost (trailing) arguments in a function's parameter list"
actually i don't know about rightmost(trailling) arguments.


Hello Bita, thank you for the question.

That means that when you define default parameters for a function, they have to be the last parameters. In other words, you can't define a default parameter and then have non default parameters after it:

void foo(int x = 0, int y) // Illegal

void foo(int y, int x = 0) // legal.

void foo(int x = 0, int y, int z = 0) // illegal

void foo(int x = 0, int y = 0, int z = 0) // legal

Default parameters simply cannot have other non-default parameters after them, reading from left to right.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 All rights reserved.