Default Arguments vs. Overloading wrt. Name Lookup?
In C++, given the alternatives:
void fun(int arg1, int arg2opt = 0);
// vs.
void fun(int arg1, int arg2);
void fun(int arg1) {
fun(arg1, 0);
}
Are there any differences for user code wanting to use this function, that
is, given any code base, which code constructs would break (at compile
time or runtime) when I were to change the first definition into the
second? (Overload resolution? Name lookup? Assigning fun to a function
pointer? Usage in templates? ...)
Or will these be the same semantically? (here are some details that I know
and that are not relevant for this question)
No comments:
Post a Comment