It is possible to set more than one default arguments with the same type at the end of the parameter list?

int myfunc(int a, int, b, int c = 42, int d = 137);
{
...
}

Now if i call myfunc(x1, x2, x3); than c=x3 and d=137?
or d=x3, and c=42 or this is not valid?

That function definition is not valid as written. Remove the semi-colon then it will be valid.

You may set as many default parameters as you like regardless of the data types. You just need to be sure that any parameters with default values are at the end of the parameter list. Any required parameters (parameters that don't have default values) must be at the beginning of the list. Once you begin assigning default values to the parameters, you may no longer have a parameter that doesn't have a default value.

int myfunc(int a, int, b, int c = 42, int d = 137); //valid declaration
int myfunc(int a = 42, int, b, int c, int d = 137); //NOT a valid declaration

Based on the provided function declaration, the call myfunc(x1, x2, x3) would produce:
a = x1
b = x2
c = x3
d = 137

However, the call myfunc(x1, x2, , x3) would produce:
a = x1
b = x2
c = 42
d = x3

In other words, what you get depends on how you call the function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.