In the function
int foo(int i, int j)
{
return i + j;
}
both i
and j
are uninitialized, so this function could be called with and only with two arguments:
foo(5, 6); // 11
Okay, but C++ featured default parameters, and made possible definitions like:
int foo(int i = 1, int j = 2)
{
return i + j;
}
Here both i
and j
has default arguments, then calls:
foo(5, 6); // 11
foo(5); // 7
foo(); // 3
are possible. So then, why this definition:
int foo(int i += 1, int j += 2)
{
return i + j;
}
And these calls:
foo(5, 6); // 14
foo(5); // 8
foo(); // 3
are impossible? Is it difficult to represent this definition or the calls causes some problems? I want to know.