I am new to c++. I have to calculate a value via equation and store that value each time whenever the function is being called. I have created an array of size 10 and calculated myValue then tried to store that value. Is this right way to do so? Will it work in way that each time whenever the function is called it will calculate and store myValue and use that value n[i-1] in the next call to calculate my value n[i]. Let's say in 1st call myvalue is 0.5. In next call it would be myValue = (1-0.3)* 0.5. Will it store all 10 values in 10 calls and use the last stored value to calculate myValue. It is not showing me any error when I am compiling it but still I have doubt.
static double
CalculatemyValue(Node* ch)
{
float gamma=0.3;
double myValue = 0.0;
int n[10];
int i = 0;
n[i] = myValue;
myValue = ((1-gamma)*n[i-1]) //previous value
return myValue;
}
staticlocal variable in there somewhere.