I searched for my problem but I couldn't find one.
I'm working with VS Code (version 1.55) in C++. I'm trying to declare 2 arrays inside a function using one of its parameters to define the width. I need this because I have to initialize them, inside the same function, in a different way given their width, like this:
double MyFunc(/*other parameters*/ int points){
double arr1[points];
double arr2[points];
if(points == 2){
// initialization
}
else if(points == 3){
// initialization
}
else if(points == 4){
// initialization
}
// Operations with the arrays etc
return 1.7; // Arbitrary value just to make this code working
}
If I save the file like this, VS Code tells me that there's a problem, which is: "expression must have a constant value -- the value of parameter "points" cannot be used as a constant". But I can compile and execute it anyway (I tried with cygwin and it's all ok). Is there a way to get rid of this "false" problem?