Q:

how to use c++ command line argument in different functions?

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;
}

A:

Use global variables:
double a;
double b;

int main (int argc , char* argv[]) 
{ 
    a=atof(argv[1]);
    b=atof(argv[2]);

    return 0;
}

double func1(double x)
{
    return x+a+b;
}

double func2(double x)
{
    return x*x+a*b;
}

Or function parameters:
int main (int argc , char* argv[]) 
{ 
    double a=atof(argv[1]);
    double b=atof(argv[2]);

    double x = 13.1;
    double someVal = func1(x, a, b);
    double someOtherVal = func2(x, a, b);

    return 0;
}

double func1(double x, double a, double b)
{
    return x+a+b;
}

double func2(double x, double a, double b)
{
    return x*x+a*b;
}

If you want your data to persist outside of a function, it either needs to be a global variable, or you need to use function parameters and return values to maintain scope of your data. Not to mention other forms of OO design as others have mentioned that could accomplish whatever you're doing... This is about as elegant as you can get.

