带省略号的功能原型 [英] Function prototype with ellipsis

查看:50
本文介绍了带省略号的功能原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道下面的函数原型是否有效.它编译的很好,但是三个时期有点让我失望,我在Google上找不到任何类似的东西.

I was wondering if the below function prototype is valid. It compiled fine, but the three period is kinda throwing me off and I couldn't find anything similar on Google.

void foo(int, ...);

谢谢!

推荐答案

是的,它是有效的.在此示例中, ... 使用 va_list 机制创建了可变参数函数.这就是在C中以及在C ++中某种程度上实现可变参数函数的方式(尽管C ++ 11的模板参数包已使该机制过时了).

Yes, it's valid. In this example, ... creates a variadic function using the va_list mechanism. This is how variadic functions are implemented in C, and to some degree in C++ (though C++11's template parameter packs have rendered this mechanism obsolete).

进一步阅读: va_arg

这篇关于带省略号的功能原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆