Comma omitted in variadic function declaration in C++

后端 未结 4 1170
余生分开走
余生分开走 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 01:17

    According to § 8.3.5.4 of the C++ standard (current draft):

    Where syntactically correct and where “...” is not part of an abstract-declarator, “, ...” is synonymous with “...”.

    In short, in C++ ... (ellipsis) is an operator in its own right and so can be used without the comma, but use of the comma is retained for backwards compatibility.

提交回复
热议问题