代码
#include
<
iostream
>
using
namespace
std;
void
swap(
int
*
i,
int
*
j){
int
temp
=
*
i;
*
i
=
*
j;
*
j
=
temp;}
void
swap2(
int
&
i,
int
&
j){
int
temp
=
i; i
=
j; j
=
temp;}
int
main(){
int
a
=
10
,b
=
20
; swap(a,b); cout
<<
a
<<
"
"
<<
b
<<
endl; swap2(a,b); cout
<<
a
<<
"
"
<<
b
<<
endl;
return
0
;}
转载于:https://www.cnblogs.com/ManMonth/archive/2010/09/03/1817360.html
转载请注明原文地址: https://win8.8miu.com/read-15385.html