I am new to programming and here is a simple question about how passing by reference works. In this program, I am calculating roots of a quadratic equation.
void getCoefficients(double &a, double &b, double &c); void solveQuadratic(double a, double b, double c, double &x1, double &x2); void printRoots(double x1, double x2); void error(string msg); int main() { double a,b,c,x1,x2; getCoefficients(a,b,c); solveQuadratic(a,b,c,x1,x2); printRoots(x1,x2); return 0; } So, my question is I seem to be passing values to getCoefficients and solveQuadratic from main program but in the function definitions of getCoefficients and solveQuadratic, I seem to be accepting references as arguments and am confused as to how this works?
getCoefficientsfills-ina, b, c, thensolveQuadraticreceives those coefficients (by value) and fills-in the rootsx1, x2, then finallyprintRootsprints thex1, x2values.main.my question is I seem to be passing values to getCoefficients and solveQuadratic from main program but in the function definitions of getCoefficients and solveQuadratic, I seem to be accepting references as arguments and am confused as to how this works?