Suppose there is a function with following prototype :
void f(int=10,int=20,int=30,int=40)
If this function is called by passing by two arguments to it , is there any way we can make sure that these arguments are treated as first and third arguments (whereas second and fourth are taken as defaults) ?
No. There is not. You can experiment with function overloading, which might let you have a bit of leeway, but ultimately you can't have ambiguous function calls, and if you write f(4, 5);
then the compiler would not possibly be able to know whether to call f(4, 5, 30, 40);
or
[/code]f(4, 20, 5, 40);[/code]
Thus you cannot do this.
Give them different names, as I suggested :) I guess you could use templates if you wanted to keep the name notionally the same, but that's probably a bad idea.