**#include <iostream>usingnamespacestd;
template <typename numtype> //定義一個類的模板class Compare{
public:Compare(numtype a,numtype b){x=a;y=b;}numtype max(){return(x>y)?x:y;}numtype min(){return(x<y)?x:y;}
private:numtype x,y;
};
int main()
{Compare <int> cmpl(3,7);cout<<cmpl.max()<<"is the Maximum of two integer numbers."<<endl;cout<<cmpl.min()<<"is the Minimum of two integer numbers."<<endl;Compare <float> cmp2(3.2323,7.658);cout<<cmpl.max()<<"is the Maximum of two integer numbers."<<endl;cout<<cmpl.min()<<"is the Minimum of two integer numbers."<<endl;Compare <char> cmp3('A','G');cout<<cmpl.max()<<"is the Maximum of two integer numbers."<<endl;cout<<cmpl.min()<<"is the Minimum of two integer numbers."<<endl;return0;
}**
**/home/andrew/文檔/Clion/untitled5/cmake-build-debug/untitled5
7isthe Maximum of two integer numbers.
3isthe Minimum of two integer numbers.
7isthe Maximum of two integer numbers.
3isthe Minimum of two integer numbers.
7isthe Maximum of two integer numbers.
3isthe Minimum of two integer numbers.Process finished withexit code 0**