C++ 中的可变参数函数模板
C++中的可变参数函数模板是一个可以接受多个参数的函数。
语法
template(typename arg, typename... args) return_type function_name(arg var1, args... var2)
示例代码
#include输出结果using namespace std; void show() //基本情况。{ cout << "I am now empty"; } template //可变参数函数 void show(T v1, T2... v2) { cout << v1 << endl; show(v2...) ; } int main() { show(7, 6, 0.04, "hi ","I am variadic function","I will show\n"); return 0; }
7 6 0.04 hi I am variadic function I will show I am now empty
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短