- #include<iostream>
- using namespace std;
- template <class T>
- int compare(const T &v1,const T &v2)
- {
- if(v1==v2)
- return 0;
- if(v1>v2)
- return -1;
- if(v1<v2)
- return 1;
- }
- void main()
- {
- cout<<compare(10,5)<<endl;
- cout<<compare(3.14,9.12)<<endl;
- }
template的简单例子
最新推荐文章于 2020-08-22 14:29:33 发布