+ 3

When I pass an array to a function,Is it passed by value or passed by reference?

Iā€™m confused.When creating a function using an array as a parameter, thereā€™s no ā€œ&ā€ before the array, which means ā€œpass by referenceā€ However, the function acts as if it were passed by reference.

2nd Feb 2018, 1:37 AM
cchuan
cchuan - avatar
6 Answers
+ 3
They turn implicitly into pointers, their size is unknown when passed to a function and they don't match with the stl container design so that they're lacking consistency. And if you make them 2d, it's even worse.
2nd Feb 2018, 5:50 AM
Timon PaƟlick
+ 1
Do you use the array class or low level bad practice C arrays?
2nd Feb 2018, 5:31 AM
Timon PaƟlick
0
C++
2nd Feb 2018, 1:47 AM
cchuan
cchuan - avatar