Should I Use Overloads or Default Parameters?--Jonathan Boccara
The answer is not obvious.
Should I Use Overloads or Default Parameters?
by Jonathan Boccara
From the article:
“Should I use overloads or default parameters”, haven’t you asked yourself that question?
When designing an interface where the user can leave the value of an argument up to the API, two approaches are possible:
Using a default parameters:
voiddrawPoint(int x, int y, Color color = Color::Black); void drawPoint(int x, int y, Color color = Color::Black);And using overloading:
void drawPoint(int x, int y); // draws a point in black void drawPoint(int x, int y, Color color);Which approach is cleaner? Which expresses better the intentions of the interface? Or is it just a matter of style?
This may be subjective, but I’m under the impression that overloading tends to have better popularity than default parameters amongst C++ developers. But I believe that both features have their usages, and it’s usefulto see what makes one or the other more adapted to a given situation.

Have you registered for CppCon 2018 in September?
Have you registered for CppCon 2018 in September?
Thank you to the over 3,000 people who participated six months ago in the Standard C++ Foundation's first-ever global C++ developer survey. Based on its success, we have decided to run these surveys about twice a year to learn about C++ usage generally across industries or in specific current domains.
Have you registered for CppCon 2018 in September? 