首页 > 编程语言 > 详细

template stuff in C++

时间:2014-11-24 06:26:02      阅读:201      评论:0      收藏:0      [点我收藏+]

1. Template function 

template <class T> // a template prefix
T func(T a, T b, T c){ // return value is T type, 3 T-typed formal parameters
   return a + b + c;
}

We could also specify different types here: 

template <class T1, class T2, class T3>
T1 func(const T1& a, const T2& b, const T3& c){ // passing 3 different types of formal parameter
   return a + b + c; // return value is T1-typed
}

 

template stuff in C++

原文:http://www.cnblogs.com/RuiYan/p/4117861.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!