第二十三模板 2重载模板

//第二十三模板 2重载模板
/*#include <iostream>
using namespace std;
const int num=10;
template<class T>
void Swap(T&rx, T&ry)
{
	 cout<<"执行函数 void Swap(T &rx, T &ry)"<<endl;
     T temp = rx;
	 ry = rx;
	 rx = temp;
}

template<class T>
void Tswap(T ar1[], T ar2[], int num)
{
     cout<<"执行函数:void Tswap(T ar1[], T ar2[], int num)"<<endl;
	 T temp;
	 for(int i=0; i<num; i++){
	     temp = ar1[i];
		 ar1[i] = ar2[i];
		 ar2[i] = temp;
	 }
}

template<class T>
void Show(T ar1[], T ar2[], int num)
{
	cout<<"执行函数 void Show(T ar1[], T ar2[], int num)"<<endl;
	for(int i=0; i<num; i++)
	{
	    cout<<"num1["<<i<<"]:"<<ar1[i]<<" num2["<<i<<"]:"<<ar2[i]<<endl; 
	}
}

int main()
{
	int x=5, y=6;
	cout<<"交换值前 x:"<<x<<" y:"<<y<<endl;
	Swap(x,y);
	cout<<"交换值后 x:"<<x<<" y:"<<y<<endl<<endl;

	int num1[num]={10,11,12,13,14,15,16,17,18,19};
	int num2[num]={0,1,2,3,4,5,6,7,8,9};
	cout<<"函数执行前:"<<endl;
	Show(num1,num2,num);
	Tswap(num1,num2,num);
	cout<<"函数执行后:"<<endl;
	Show(num1,num2,num);	
    return 0;
}
*/

  

posted @ 2012-10-04 13:36  简单--生活  阅读(119)  评论(0编辑  收藏  举报
简单--生活(CSDN)