Arguments are passed by value, unless the function signature specifies otherwise:
- in
void foo(type arg)
,arg
is passed by value regardless of whethertype
is a simple type, a pointer type or a class type, - in
void foo(type& arg)
,arg
is passed by reference.
In case of arrays, the value that is passed is a pointer to the first element of the array. If you know the size of the array at compile time, you can pass an array by reference as well: void foo(type (&arg)[10])
.