I am new to C++ and would like to check what does (&array) trying to represent here.
template <class var, size_t N>
var sum_numbers(var (&array)[N]) {
var sum = 0;
for (size_t f1=0; f1<N; f1++) {
sum = sum + array[f1];
}
return sum;
}
If i only need to loop through the array and count the number of occurrence for each loop, do i need to put (&array) or can i just change the code to
template <class var, size_t N>
var sum_numbers(var [N]) {
var sum = 0;
for (size_t f1=0; f1<N; f1++) {
sum = sum +1;
}
return sum;
}