C++ — Function default argument value depending on argument name in C++

'y' was not declared in this scope — function is accepted in Clang, but rejected in GCC

Flutter Developer
2 min readOct 8, 2021

--

If one defines a new variable in C++, then the name of the variable can be used in the initialization expression, for example:

int x = sizeof(x);

And what about default value of a function argument? Is it allowed there to reference the argument by its name? For example:

void f(int y =

--

--