可变参数模板,自己尝试了个例子,如下:

 // variadicTemplates.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include "stdio.h"
#include "iostream"
#include "string" using namespace std; template <class... T>
void fun(T... p)
{
cout << sizeof...(p) << endl;
} template <class T>
void fun_print(T t)
{
cout << t << endl;
} template <class T, class ...args>
void fun_print(T head, args... res)
{
cout << head << endl;
fun_print(res...);
} template < typename T >
T fun_sum(T t)
{
return t;
}
template<typename T, typename ...types>
T fun_sum(T head, types ... res)
{
return head + fun_sum(res...);
} int _tmain(int argc, _TCHAR* argv[])
{
fun(, , , , );
fun(1.1, "", );
fun(true, 'a');
fun_print(, true, , 4.9, "");
cout << fun_sum(, , , ) << endl; getchar();
return ;
}

最新文章

  1. C# 设置word文档页面大小
  2. Spring任务调度之Quartz
  3. BZOJ2933: [Poi1999]地图
  4. WinForm------TreeList修改节点图标和按钮样式
  5. UILabel 的属性(用法)方法
  6. 那些年不错的Android开源项目
  7. Oracle Flashback Technologies - 闪回查询
  8. POJ1011 (DFS+剪枝)
  9. SSDT Hook
  10. 实用lsof常用命令行
  11. cvc-complex-type.2.4.c: The matching wildcard...
  12. python 使用 PIL 和 matplotlib 获取图片像素点处理之后再写入
  13. case when 和 decode 的比较分析
  14. Android UI(三)SlidingMenu实现滑动菜单(详细 官方)
  15. canvas.drawImage()方法详解
  16. python ftp文件夹文件递归上传推送
  17. MP实战系列(十八)之XML文件热加载
  18. 【BZOJ-2329&amp;2209】括号修复&amp;括号序列 Splay
  19. ios 加密解密工具类字符判断等
  20. C#可选参数、命名参数、参数数组

热门文章

  1. docker运行tomcat
  2. Omi框架学习之旅 - 组件通讯(data通讯) 及原理说明
  3. jetty 客服端 与服务端
  4. IOS 上架到App Store被拒的常见问题总结
  5. 自己动手写把”锁”---LockSupport深入浅出
  6. svg矢量图在flex布局中样式扭曲的问题
  7. D. Cutting Out
  8. 个人博客作业-Week1
  9. 个人作业 Last
  10. jdk自带的jvisualvm-监控远程linux