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

#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();
}

原文地址:https://www.cnblogs.com/zztong/p/6695322.html