#include <iostream>
#include <vector>
#include "stdarg.h"
using namespace std;
template<class T>
vector<T>* funs(T a, ...)
{
va_list params;
va_start(params, a);
T now;
vector<T> *ve = new vector<T>;
ve->push_back(a);
while (a)
{
now = va_arg(params, T);
if (now )
{
ve->push_back(now);
}
else
{
ve->pop_back();
break;
}
}
va_end(params);
return ve;
}
int main()
{
vector<int> *ve = funs(1,2,3,4,5,6,7);
for (auto const & child : *ve)
{
cout<<child<<endl;
}
return 0;
}
c++多参数
最新推荐文章于 2025-03-13 17:23:05 发布