#include <iostream>
#include "library.h"
void hello() {
std::cout << "Hello, World!" << std::endl;
}
#ifndef MYSHAREDLIB_LIBRARY_H
#define MYSHAREDLIB_LIBRARY_H
// 打印 Hello World!
void hello();
// 使用可变模版参数求和
template <typename T>
T sum(T t)
{
return t;
}
template <typename T, typename ...Types>
T sum(T first, Types ... args)
{
return first + sum<T>(args...);
}
#endif
因为省略号就有无限的可能性。
往无限去拓展就是无限复制 带省略号部分,其之前的运算符也是重复叠加。