#include <QCoreApplication>
#include <iostream>
using namespace std;
//函數模板
template<typename T>
bool equivalent(const T&a, const T&b)
{
return !(a<b)&& !(b<a);
}
//類模板
template<typename T=int>//默認參數
class Bignumber{
typedef T value_type;
public:
Bignumber(value_type a):
m_v(a)
{
}
inline bool operator <(const Bignumber &obj)const
{
return m_v< obj.m_v;
}
private:
value_type m_v;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Bignumber<> x(1), b(1);
bool ret = equivalent(x,b);//函數模板自動推導
cout<<ret<<endl;
cout<<equivalent<double>(5,1);//函數模板特化
while (1) {
}
return a.exec();
}