knn
knn copied to clipboard
std::pair<double, int> squaredDistances[data->rows];
I have a question in knn.cpp file and in 26th rows: std::pair<double, int> squaredDistances[data->rows];
The length of array squaredDistances is not sure. How does this implement?
My compile environment is VS 2013.
Hi there,
That is a good point. The length of squaredDistances is dynamic, which is ok when compiling with g++, but it seems that the Visual Studio compiler does not handle it. You can use the function "alloca" instead, to allocate the array on the stack.
Reference: http://stackoverflow.com/questions/312116/c-array-size-dependent-on-function-parameter-causes-compile-errors#312125