Newish to C++ but been researching alot so please bear with me.
I've been trying to use 1 function to relate 8 global double variables [ mA mB ... mG which ranges from values 1 to 10] to another double value. I first obtain these 8 variables by obtaining the data from a csv file, throwing them to an array and then equating the set global variables. This all works fine. I cout the values correctly.
mA =10, mB=1 ,.... mG=2
However I need to use these variables to relate to another set value. So i Use:
double Function1(double Mvalue1)
{
if (Mvalue1 == 1) { double value = 10; return value ; }
if (Mvalue1 == 2) { double value = 20; return value ; }
.... // cont to 10 only increasing value by 10
if (Mvalue1 == 10) { double value = 110; return value ; }
}
void VarFunction()
{
mA2= Function1(mA); **//SHOULD output 110**
cout << "Vaule A " << mA2 << endl;
mB2= Function1(mB); **//SHOULD output 10**
cout << "Vaule B " << mB2 << endl;
....//.... 8 times
mG2 = Function1(mG); **//SHOULD output 20**
cout << "Vaule G " << mG2 << endl;
}
int main()
{
VarFunction()
return 0;
}
So the output i get here is
Value A 110
Value B -1.#IND
....
Value G -1.#IND
Why isnt the next call of function1 with the next variable not working?