for the function having prototype....
void fun(int = 10, int = 20, int = 30, int = 40);
how to make sure that when it is called with two arguments
these two are treated as the 1st & 3rd arguments
while the 2nd & 4th take the default values???????????
Not (currently) possible. Try to search before you ask, there is a recent thread on the topic.
It is technically possible to achieve the effect by overloading, but that limits the ability to use default arguments.
This isn't a particularly good idea; at the least it will make it VERY easy for a user of these functions to make an error, and get the arguments in a wrong order. So there would be a maintenance nightmare associated with the any function that calls fun().
void fun(int, int, int, int = 40)
void fun(int a, int b)
fun(a, 20, b);
void fun(int a = 10)
fun(a, 20, 30, 40);
IMHO, any coder who uses this sort of technique in production code that someone else has to reuse should be summarily shot.