I just had a discussion with a colleague at work who is responsible for the building of our rather large software product. To reduce file size, time used, and general hassles, he wants to rebuild as little code as possible when we make code changes. In this case, I had made a code change like so:
void Func1(int a); // Original
void Func1(int a, int b = 0); // New
Func1 is already being used at a lot of places in client code, and I didn't want to change that code in umphteen places, hence the default parameter. My code resides in a dll, and the client code resides in other dlls (not that I think that has much bearing on the answer to my question).
Now, I say that even though there is a default parameter, the client code, while not needing to be changed, must nevertheless be recompiled with my code's updated .h file, because the only thing that the default parameter does, is having the compiler quietly insert the default parameter value as parameter 2 at every call to Func1. The binary Func1 doesn't even know about its own default value; it expects 2 parameters of type int, and that's it.
My colleague begs to differ, thinking that the function knows that it has a default value, and uses that if the client passes only one parameter.
Who is right (or are we both wrong, and there is a 3rd answer)?