+ 1

How do i declare arrays in a function parameter?

I tried to declar an array in the function parameter this way : arr[3]= {1,1,1,}, but it didn't work, why?

5th Mar 2017, 7:07 PM
Giovanni Del Gallo
Giovanni Del Gallo - avatar
1 Resposta
0
You can't define an array with a default argument in c++. The argument arr[3] is actually just a pointer to memory. Also, the 3 in the argument is actually just a hint to the programmer to the expected size as well. And the calling code can pass an array of any size to the function.
5th Mar 2017, 7:13 PM
Alexandre Sabourin
Alexandre Sabourin - avatar