相关代码 |
|
#include template void swap(X &a, X &b); void swap(int &a, int &b); int main(void) { int i=10, j=20; float x=10.1, y=23.3; char a='x', b='z'; cout cout cout swap(i,j); // explicitly overloaded swap swap(a,b); swap(x,y); cout cout cout } template void swap(X &a, X &b) { X temp; temp = a; a = b; b = temp; } void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; cout }
相关资源 |
|