fun_template

来源:互联网 发布:mac 扫描局域网ip 编辑:程序博客网 时间:2024/06/16 15:58
# include <iostream>using namespace std;template <typename T>  //函数模板T abs(T x){return x<0?-x:x;}int main(int argc, char **argv){int n=-5;double d = -5.5;cout << abs(n) << endl;//根据实参类型产生模板函数cout << abs(d) << endl;return 0;}

0 0