C++ pass an array by reference
Arrays can only be passed by reference, actually: void foo(double (&bar)[10]) { } This prevents you from doing things like: 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: template<typename T, size_t N> … Read more