模板特化(专门化)
来源:互联网 发布:java中类中的static 编辑:程序博客网 时间:2024/06/04 23:21
#include<iostream>
#include<string>
using namespace std;
template<typename T>
int max(T &a,T &b){
if(a>b){
return 1;
}else if(a<b){
return -1;
}else{
return 0;
}
}
template<>
int max<double>(double &a,double &b){
cout<<"使用特化模板"<<endl;
if(a>b){
return 10086;
}else if(a<b){
return-10086;
}else{
return 0;
}
}
int main(){
int a=10;
int b=10;
cout<<max(a,b)<<endl;
double aa=10.68;
double bb=9.36;
cout<<max(aa,bb)<<endl;
return 0;
}
- 模板专门化(特化)
- 模板特化(专门化)
- 模板特化
- 模板特化
- 模板特化
- 模板特化
- 模板特化
- 模板特化
- 模板特化
- 模板特化
- 模板特化,全特化,偏特化,全部特化,部分特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化 .
- 模板特化和偏特化
- 模板特化和偏特化
- 现在比较流行的一种新的清除浮动的方法
- 关于电感和磁珠
- SOJ 2325:Word Transformation _floyd
- Linux:-bash: ***: command not found,系统很多命令都用不了,均提示没有此命令
- 联想杨元庆自掏近两千万奖员工,联想PC年内或超惠普成全球第一
- 模板特化(专门化)
- Chapter 16 Templates and Generic Programming
- http://acm.hdu.edu.cn/showproblem.php?pid=2586&&How far away ?
- 面试指南 笔记(一)基本概念
- hibernate的查询语法以及返回类型
- 面试指南 笔记(二) 编程规范
- 四极管:转载老罗
- 面试指南 笔记(三) 数据类型
- linux根文件系统制作