0
이 배열을 참조로 전달하려고하지만 내 코드가 함수를 가져올 수없는 것 같습니다. 도움?참조로 배열을 전달하는 방법은 무엇입니까?
#include <iostream>
using namespace std;
void print(int (&array)[], int lower_bound, int upper_bound);
int main()
{
// generate array
const int SIZE = 20;
int array[SIZE];
for (int i = 0; i < SIZE; i ++) array[i] = rand()%500;
// end generate array
print(array,0,19);
return 0;
}
void print(int (&array)[], int lower_bound, int upper_bound)
{
for (int i = lower_bound; i <= upper_bound; i ++) cout << i << " : " << array[i] << endl;
}
'void print (int array, int lower_bound, int upper_bound); ' – mah
@ 40two 배열은 포인터가 아닙니다. – juanchopanza
@ 40two : 오해를 퍼트 기 전에 [comp.lang.c FAQ] (http://www.c-faq.com/)의 6 항 (대부분 C++에도 적용됨)을 읽어주십시오. 배열은 포인터가 아닙니다. –