Variable number of arguments in C++?

后端 未结 17 2019
-上瘾入骨i
-上瘾入骨i 2020-11-21 23:13

How can I write a function that accepts a variable number of arguments? Is this possible, how?

17条回答
  •  庸人自扰
    2020-11-21 23:44

    C-style variadic functions are supported in C++.

    However, most C++ libraries use an alternative idiom e.g. whereas the 'c' printf function takes variable arguments the c++ cout object uses << overloading which addresses type safety and ADTs (perhaps at the cost of implementation simplicity).

提交回复
热议问题