title: C++ passing by reference or by value?
body: <p>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.</p>
  
  <pre><code>void getCoefficients(double &amp;a, double &amp;b, double &amp;c);
  void solveQuadratic(double a, double b, double c, double &amp;x1, double &amp;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;
  }
  </code></pre>
  
  <p>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?</p>