(资料图)
void test01() { int a = 10; int b = 20; mySwap(a,b); // 2 编译器在函数模版被调用时,进行第二次编译。会把泛型T替换成具体的类型 /* void mySwap(int &a, int &b){ int tmp = a; a = b; b = tmp; } */ cout << "a = " << a << endl; cout << "b = " << b << endl;