Comma omitted in variadic function declaration in C++

后端 未结 4 1102
余生分开走
余生分开走 2021-02-05 00:14

I am used to declaring variadic functions like this:

int f(int n, ...);

When reading The C++ Programming Language I found that the dec

4条回答
  •  死守一世寂寞
    2021-02-05 00:51

    With int f(int n, ...); and int f(int n...);, as you can see, both , ... and ... has the same meaning. Comma is optional.

    But this int printz(...); is valid in C++ while int printz(,...); is not (at least one named parameter must appear before the ellipsis parameter). That's why you can have just (...), even though the arguments passed to such function are not accessible.

提交回复
热议问题