c++ - 用C和C++调用的(…)是什么?

标签 c++ c terminology ellipsis variadic

...的用途之一是在C和C++中表示 variadic 实体。

它叫什么名字?

以这种方式使用时,它被归类为运算符还是其他?

有关...的其他详细信息吗?

编辑:
我知道...的目的。我在问它的​​名称和分类,我希望它在C和C++中都相似。

最佳答案

它是标点之一。

6.4.6  Punctuators
Syntax punctuator:
     one of  [    ]    (    )    {   }    .    ->
             ++   --   &    *    +   -    ~    !
             /    %    <<   >>   <   >    <=   >=    ==   !=   ^   |   &&   ||
             ?    :    ;    ...
             =    *=   /=   %=   +=  -=   <<=  >>=   &=   ^=   |=
             ,    #    ##
             <:   :>   <%   %>   %:   %:%:

在函数声明中,它称为省略号

某些编译器C语言扩展也使用省略号。
示例-gcc开关/案例范围扩展
const char *test(unsigned num)
{
    switch(num)
    {
        case 0 ... 9:
            return "the value is in the 0 to 9 range";
        case 10 ... 99:
            return "the value is in the 10 to 99 range";
        default:
            return "out of tested range";
    }
}

https://godbolt.org/z/YBLma-

关于c++ - 用C和C++调用的(…)是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59697071/

相关文章:

c++ - 按值返回的函数的 return 语句中的初始化

c - 我怎么知道在发送信号之前是否已经创建了所有进程?

oop - 依赖/依赖是什么意思?

c++ - 强制 std::string 使用 unsigned char(0 到 255)而不是 char(-128 到 127)

c++ - 如何从 C++ 文件中读取带逗号的数字?

c++ - (C++) 试图完成一个快速程序,但我不确定哪里出错了?

cassandra - 对 Cassandra 术语感到困惑(行与分区)

java - 如何以编程方式将 IP 数据包字节写入 PCAP 文件格式?

c - 错误 : Address already in use while binding socket with address but the port number is shown free by `netstat`

terminology - 粗粒度与细粒度