This code will work if in the very first declaration of the function the last parameter has a default value, something like the following:
//declaration void error(char const *msg, bool showKind, bool exit = false);
And then in the same scope, you can provide default values ββfor the other arguments (on the right side) in a later declaration:
void error(char const *msg, bool showKind = true, bool exit);
which can be called like:
error("some error messsage"); error("some error messsage", false); error("some error messsage", false, true);
Online Demo: http://ideone.com/aFpUn
Please note that if you specify a default value for the first parameter (left), without specifying a default value for the second, it will not compile (as expected): http://ideone.com/5hj46
Β§8.3.6 / 4 states:
For non-template functions, by default arguments can be added later function declarations in the same scope.
An example from the standard itself:
void f(int, int); void f(int, int = 7);
The second ad adds a default value!
Also see Β§8.3.6 / 6.
Nawaz Apr 12 2018-11-11T00: 00Z
source share