简单利用模板的例子
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;
}
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++实现JNI接口需要注意的事项
- 关于指针的一些事情
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- Mootools 1.2教程 函数
- autoit InputBox 函数
- 文件遍历排序函数
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- ASP下经常用的字符串等函数参考资料
- PostgreSQL教程(五):函数和操作符详解(1)
- DOS批处理 函数定义与用法
- asp Chr 函数 数字转字母的方法
- Lua中的函数精讲笔记
- Lua中的闭合函数、非全局函数与函数的尾调用详解
- Lua中调用C++函数示例
- Lua实现split函数
- Lua常用时间函数使用实例
- Lua函数与字符串处理简明总结
- Lua教程(一):在C++中嵌入Lua脚本