For calculations inside a function I need data/variables from outside this function (not passed in as parameters) - how can one make it accessible inside the function? Something corresponding to COMMON in Fortran.
const int iNum;
Float_t x_point[3],y_point[3],error_y[3];
for (int i=0;i<iNum; i++) {
// chi square is the quadratic sum of the distance from the point to the function weighted by its error
double delta = (y_point[i] - fit_function(x_point[i],par))/error_y[i];
chisq += delta*delta;
}
f = chisq;
return;
}
they cant by accessed out side of [void calc_chi_square{ acces ONLY here}]
when calc_chi_square ends the variables isnt exist any longer
you need to declare them somewhere outside where they exsis at the time you wana use them and are accessible by you rutine from which you wana acces them