通用函数模板可变参数(参数个数、参数类型都可以不一样):
#include <iostream>
using namespace std;
//这个空函数必须有
void showall(){
}
template <typename T,typename... Args>
void showall(const T &value,const Args&... args){
cout<<value<<endl;
showall(args...);//继续传递,相当于每次调用就少一个参数,直到调用到上面参数为空的函数为止,因此上面的showall()函数必须存在
}
int main(int argc, char *argv[])
{
int i1=10,i2=11,i3=12;
showall(10,'a',"hello world",12.28);
showall("hello world",12.28);
return 0;
}