引用传递和值传递一直是个令人头疼的问题。下面的这个例子是一个新的佐证,很容易理解。 #include <cstdlib> #include <iostream> using namespace std; void setValue(int a) { a=5; } void setValue2(int a[]) { a[0]=5; } int main(int argc, char *argv[]) { int a=0; int b[1]={0}; setValue(a); setValue2(b); cout<<a<<endl; cout<<b[0]<<endl; system("PAUSE"); return EXIT_SUCCESS; } 输出: 0 5 ……