#include<iostream>
#include<string>
using namespace std;
template<typename T>
void Swap(T &a, T &b);
int main()
{
string i = "abc", j = "cba";
cout << i << ":" << j << endl;
Swap(i, j);
cout << i << ":" << j << endl;
Swap(i, j);
cout << i << ":" << j << endl;
cin.get();
return 0;
}
template<typename T>
void Swap(T &a, T &b)
{
T temp = a;
a = b;
b = temp;
}
模板函数
最新推荐文章于 2023-12-25 22:13:20 发布