Passing an array of unknown size by reference in c++ -
i have 4 sorted integer arrays, i'm trying merge 1 huge sorted array.
i merge , b gives me int array called x merge c , d gives me int array called y merge x , y z, final product.
the merge function doing same each time, storing results different array want pass in reference.
i want this:
void mergesort(int arr1[], int arr2, int &result[]){ ... }
but error "array of reference not allowed". best way this?
the syntax pass array reference in c++
int (&result)[size]
note need know size
@ compile time. not want here , suggest use vector<int>
.
Comments
Post a Comment