重载:函数名相同,参数类型和个数不同
模板:函数名相同,个数相同,参数类型不同
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <IOSTREAM>usingnamespacestd;template <typename T>T Max(T a, T b){    if(a > b) returna;    elsereturnb;}voidmain(){    inta = 1, b = 2;    floatc = 1.1, d = 2.1;    cout << Max(a, b) << endl;    cout << Max(c, d) << endl;} | 
注:模板是一种类型
inline在申明的时候加上即可。。
原文:http://www.cnblogs.com/jsy306/p/3783797.html