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

简单利用模板的例子

2015-12-12 15:34 183 查看
#include<iostream>

using namespace std;

template<class Any>

void Swap(Any &a, Any &b);

int main()

{

int i = 20;
int j = 10;
Swap(i, j);
cout << i << "\t" << j<<endl;
cin.get();
cin.get();
return 0;

}

template<class Any>

void Swap(Any &a, Any &b)

{
Any temp;
temp = a;
a = b;
b = temp;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ C++primer 函数