可变参数模板:template<class T, class... Args>
参考链接:https://blog.csdn.net/qq_44194231/article/details/113436004
参考链接2:https://blog.csdn.net/wangx_x/article/details/122374408
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#include <string>
#include <set>
typedef long long ll;
using namespace std;
void MyPrint()
{
return;
}
template<class T, class... Args>
void MyPrint(T t, Args... args)
{
cout << t << endl;
MyPrint(args...);
}
int main()
{
freopen("D:/c++/dev-data/in.txt", "r", stdin);
MyPrint("asdasd", 1, 1.789, "asd");
return 0;
}
结果:
asdasd
1
1.789
asd