Thread View: gnu.g++
1 messages
1 total messages
Started by Jim Knutson
Tue, 18 Jul 1989 02:09
What am I missing?
Author: Jim Knutson
Date: Tue, 18 Jul 1989 02:09
Date: Tue, 18 Jul 1989 02:09
30 lines
1044 bytes
1044 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads