Programa C ++ Pass by Reference
IBM explica el pase de C ++ por referencia en el siguiente ejemplo (fuente incluida).
Si yo cambiaravoid swapnum...
avoid swapnum(int i, int j)
, ¿se volvería pasar por valor?
// pass by reference example
// author - ibm
#include <stdio.h>
void swapnum(int &i, int &j) {
int temp = i;
i = j;
j = temp;
}
int main(void) {
int a = 10;
int b = 20;
swapnum(a, b);
printf("A is %d and B is %d\n", a, b);
return 0;
}