knutson@marconi.sw.mcc.com (Jim Knutson) (07/18/89)
Why shouldn't the compiler at least flag this with a warning? If not
at parse time, then at least at load time. Aren't the function names
munged to include parameter types?
#include <stream.h>
int data[10] = { 4, 7, 12, 5, 0, 3, 87, 445, -2, 10 };
main()
{
int j, i;
void swapit(int i, int j); // <<< Non-reference parameters
for (j = 0; j < 10; j++) {
for (i=j+1; i < 10; i++) {
if (data[i] < data[j])
swapit(data[i],data[j]);
}
}
for (i = 0; i < 10; i++) cout << data[i] << " ";
cout << "\n";
}
// vvvvvv Reference parameters
void swapit(int& i, int& j) { int temp = i; i = j; j = temp; }
--
Jim Knutson
knutson@mcc.com
cs.utexas.edu!milano!knutson