Tmp爲用戶自定義的名字
template< typename Tmp>
適用於所有類型
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
template<typename Tmp>
Tmp Add( Tmp a, Tmp b) {
return a + b ;
}
int main() {
double x = 5.8, y = 9.3;
cout << Add(x, y) << endl;
string a = "Hello ", b = "World!";
cout << a + b << endl;
return 0;
}