函数模板返回两个值的最小值,确保能正确处理字符串
2016-04-03 11:17
357 查看
#include<iostream.h> #include<string.h> template<class t>t *mine(t *a,t *b) { return strcmp(a,b)<0?a:b; } void main() { cout<<mine("hello","welcome")<<endl; } ***************************************************************************************************************************************** #include<iostream.h> template<class t> class array { t a[3][3]; public: void intput() { t b[3][3]; for(int i=0;i<3;i++) for(int j=0;j<3;j++) { cin>>b[i][j]; a[i][j]=b[i][j]; } } void output() { for(int i=0;i<3;i++) for(int j=0;j<3;j++) cout<<a[i][j]<<endl; } }; void main() { array<int> c; c.intput(); c.output(); }
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- 关于指针的一些事情
- 设计模式之行为型模式 - 调用行为的传递问题
- [div+css]晒晒最新制作专题推广页模板
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- 2008大学生入党申请书 模板
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- IMAIL多语言模板两套Outlook&Gmail模板下载
- C++联合体转换成C#结构的实现方法
- C++高级程序员成长之路
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析
- C/C++数据对齐详细解析
- C++基于栈实现铁轨问题
- C++中引用的使用总结
- 使用Lua来扩展C++程序的方法