void swap1(int& a, int& b){ //swap1(m,n) int t = a; a = b; b = t; } void swap2(int* a, int* b){ //swap2(&m,&n) int t = *a; *a = *b; *b = t; }
这两段代码都发挥了一样的作用,第二段的原理我知道,是改变了地址里的内容,第一段的作用也是这样吗?我听过一些c++的课,但对这个有些模糊,好像是叫什么引用来着。