This question already has an answer here:
- what is the use of … in c++ 2 answers
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, ...);
Thanks!
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).
Further reading: va_arg
来源:https://stackoverflow.com/questions/26768404/function-prototype-with-ellipsis