Default parameter is a default value for a parameter to a function. The default value can be provided to the list of parameters starting from the right end. Ex: for a function fun(int i, float f, long l), you can specify default value as fun( int i, float f, long l = 1000) but not fun( int i = 10, float f, long l).
You can specify default value for overloaded function provided it is still different from the other forms when the default value is applied.
Ex: void Fun( int i ); void Fun( int i, int j, float f); void Fun( int i, int j = 10); // Ambiguous call.
the third version is not allowed as the compiler cannot decided which of the two to use when there is a call to this function like Fun(10) since it could either be Fun(10) or Fun(10,10). |