I have a widely used c++ library which holds a method such as:
foo();
I want to overload this function to have a default argument such as:
foo(bool verbose=false);
does this change force me to recompile every code that uses this function?
can’t a call to foo() without the argument keep working as the no-args-signature didn’t change?
by the way – I’m using gcc
thanks
Yes, and the compile will fail, since there will be an ambiguity.
What you can do is overload the function like so:
and treat the case
foo()as if the parameter was false.This wouldn’t require a re-compilation. You’d just have two functions:
instead of one with a default paramter.