Can an unnamed parameter of function have a default value?

后端 未结 4 1395
北荒
北荒 2021-02-20 00:36

Is the following code legal in C++?

void f(void* = 0)
{}

int main()
{
    f();
}

Which page of the C++ standard states that this usage is lega

4条回答
  •  星月不相逢
    2021-02-20 01:22

    Yes, it is legal.
    The syntax productions given for function parameters in clause 8.3.5/1 allow a parameter declaration without an identifier, but with an assignment expression (as initialiser).

提交回复
热议问题