I write a code like this:
void Print(const int & dataArray[], const int & arraySize) { // problem
for(int i = 0; i<arraySize; i++) {
cout << dataArray[i] << " ";
}
cout << endl;
}
in mian() function:
`
int iArray[14] = { 7, 3, 32, 2, 55, 34, 6, 13, 29, 22, 11, 9, 1, 5 };
int numArrays = 14;
Print(iArray, numArrays);
....
`
the compiler says that arrays of references are illegal, why it is illegal ??
I see the <effective c++>, it says recommend we use the const and reference, I just try to implement it(I'm a beginner), I also want to know in the void Print(const int dataArray[], const int & arraySize)
parameter I use const, & to qualify the arraySize, is it right?(or is it much better than int arraySize or const int arraySize?), I want also use const,& to dataArray[], but I failed.