#include <cmath>
#include <vector>
#include <iostream>
#include<stdlib.h>
using namespace std;
template<typename T>
void myswap(T& a, T& b) {
T temp = a;
a = b;
b = temp;
}
void test() {
int a = 10;
int b = 20;
myswap(a, b);
cout << "a=" << a << endl;
cout << "b=" << b << endl;
myswap<int>(a, b);
cout << "a=" << a << endl;
cout << "b=" << b << endl;
}
int main() {
test();
}
函数模板基本语法
最新推荐文章于 2024-07-17 22:53:57 发布