C++11
1.Variadic Template
可以传入任意数量的参数,并且参数的类型不定。
void printX(){}
template<typename T, typename... Types>
void printX(const T& firstArg, const Types&... args)
{
cout<<firstArg<<endl;
printX(args...);
}
其中,...是pack包,用于模板参数中(typename...)表示模板参数包,用于参数类型表示参数类型包(Types...),用于参数表示函数参数包(args...)。