注意:每个不定类型或参数中...的位置!!!
test01是变化参数的函数模板;
test02是01的升级案例;
test03是类模板的变化参数的类递归继承。
#include <iostream>
#include <thread>
#include <bitset>
#include <functional>
#include <string>
using namespace std;
// test01() start
void print() {}
template<typename T, typename... Types>
void print(const T& firstArg, const Types& ...args) {
cout << firstArg << endl;
cout << "args...的长度:" << sizeof...(args) << endl;
print(args...);
}
void test01() {
print(7.5, "hello", bitset<16>(377), 42);
}
// test01() end
//test02() start
class Customer {
public:
Customer(int f, int l, int n) : fname(f), lname(l), no(n){}
int fname;
int lname;
int no;
};
template<typename T>
inline void hash_combine(size_t& seed, const T& val) {
seed ^= hash<T>()(val) + 0x9e3779b9 + (