本文实现函数的可变参数模板(Variadic Templates)
#include<iostream>
using namespace std;
void print() {}
template<typename T, typename... Types>
void print(const T& head, const Types&... tails)
{
cout << head << endl;
print(tails...);
}
int main()
{
print(44, "April", 9.17);
return 0;
}执行结果

版权声明:本文为liyazhen2011原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。