In the same scope, it’s not possible to have different values for default arguments. For example, this would be an error:
void foo(int i = 0){ cout << i;}void foo(int = 1);//error
But default arguments can indeed take different values in different scopes. For example:
int Func(void){ foo(int = 1);//ok, 1 will be used as the default value in the scope ofthis function}
To enforce this, a parameter must be supplied to the function. Declare the function without a default parameter:
int Func(void){ foo(int);//disable the default parameter. foo(1);//ok. foo();//error, function foo() takes one parameter.}
The opposite is also true--a function can be declared to take adefault parameter even if it’s not defined that way.
void foo(int i){ cout << i;}int Func(){ void foo(int = 1);//enable default parameter foo();//ok.}