正在加载图片...
template<typename T void swap (T& first, T& second) T temp first first second; second tempi (){ int a, bi double x,yi char m ni swap(a, b)i// swap<int>(a, b) swap(x, y)i// swap<double>(x, y) swap(m, n)i// swap<char>(m, n)i COMP 152COMP152 12 template<typename T> void swap (T& first, T& second) { T temp = first; first = second; second = temp; } main() { int a,b; double x,y; char m,n; swap(a,b); // swap<int>(a,b); swap(x,y); // swap<double>(x,y); swap(m,n); // swap<char>(m,n); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有