I can routinely read parameters (e.g a and b ) as input to a c++ code by command line argument.
Q: how can I use these 2 parameters in several other functions (not the main), so they act similar to "global" variables.
here is an example, the scope a and b is just the main and not for func1 and func2. how to make a and b visible also for func1 and func2? Thanks for help!
int main (int argc , char* argv[])
{
double a=atof(argv[1]);
double b=atof(argv[2]);
return 0;
}
double func1(double x)
{
return x+a+b;
}
double func2(double x)
{
return x*x+a*b;
}