1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 |
#ifndef SWAP_H_INCLUDED #define SWAP_H_INCLUDED #include <iostream> using
namespace std; struct
Job { string name; int
salary; }; template
< typename
T> void
Swap(T &a, T &b); template
<> void
Swap<Job>(Job &, Job &); template
< typename
T> void
Swap(T &a, T &b) { T tmp = a; a = b; b = tmp; } template
<> void
Swap<Job>(Job &a, Job &b) { int
tmp; tmp = a.salary; a.salary = b.salary; b.salary = tmp; } #endif // SWAP_H_INCLUDED |
原文:http://www.cnblogs.com/jesse-deng/p/3730075.html