I have the following C++ function, trying to return an array of float
:
float* get_my_weights(int e, int n, float a, float b) {
float weights[10] = {1};
weights[0] = e + n + a + b;
return weights;
};
During the compilation, I got the following errors:
myFunction:4:12: error: address of stack memory associated with local variable 'weights' returned[-Werror,-Wreturn-stack-address]
return weights;
^~~~~~~
1 error generated.
What did I do wrong here?