一、可变参函数模板
template.h
#pragma once
#include <iostream>
#include <map>
void myfunct2()
{
std::cout << "终止调用" << std::endl;
}
template <typename T, typename...U>
void myfunct2(const T& firstarg, const U&... otherargs)
{
std::cout << "收到的参数值是:" << firstarg << std::endl;
myfunct2(otherargs...);
}
main.cpp
#include <iostream>
#include "template.h"
using namespace std;
int main()
{
myfunct2(10, "abc", 12.7);
}
输出:
收到的参数值是:10
收到的参数值是:abc
收到的参数值是:12.7
终止调用
二、可变参类模板
template.h
#pragma once
#include <iostream>
#include <map>
template <typename... Args> class myclasst {};
template <typename First, t