If you try it just like this:

1
void foo(double& *arr)

Seems it doesn’t work.

Arrays can only be passed by reference, actually:

1
2
3
4
void foo(double (&arr)[10])
{
// Example
}

or

1
2
3
4
void foo(double (&arr)[])
{
// Example
}

(Be aware that when matching, double [10] and double [] are different types. If you have an array of an unknown dimension, it will match the second, but not the first, and if you have an array with 10 elements, it will match the first but not the second. )

This prevents you from doing things like:

1
2
double arr[20];
foo(arr); // won't compile

To be able to pass an arbitrary size array to foo, make it a template and capture the size of the array at compile time:

1
2
3
4
5
template<typename T, size_t N>
void foo(T (&bar)[N])
{
// use N here
}

You should seriously consider using std::vector, or if you have a compiler that supports C++11, std::array.