您的位置:首页 > 编程语言 > C语言/C++

函数模板返回两个值的最小值,确保能正确处理字符串

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++ 模板