#include < iostream >
#include < string >
using namespace std;
template < typename T >   //通用函数模板定义
T add( T x, T y )
{
    return x + y;         //返回两变量的和
}

template< >
char* add( char* x, char* y ) //针对char*类型，特化模板add
{
    return strcat ( x, y );  //定义库函数，连接字符串
}
int main( )             //理解模板特化
{
    cout<<"2 + 3 = "<<add( 2, 3 )<<endl;       //用int实例化add
    cout<<"2.2 + 3.3 = "<<add( 2.2, 3.3 )<<endl; //用double实例化add
    char s1[20] = " Hello ";
    char s2[20] = "Template";
    cout<<"Hello + Template = "<<add( s1, s2 )<<endl;  //用char*特化add
    return 0;
}
