Login  Register

Const reference with primitive types?

Posted by leogargu on Jan 23, 2015; 6:41pm
URL: https://forum.librecad.org/Const-reference-with-primitive-types-tp5711010.html

Hi everybody,
 
I was wondering why a const reference is used in the function below (in rs_ellipse.cpp) for the doubles cx, a0, a1. Given that those are primitive types, what is the benefit of doing this vs say, double cx=data.center.x, or const double cx=data.center.x ?

double RS_Ellipse::areaLineIntegral() const
{
   (...)
    const double& cx=data.center.x;
    const double aE=getAngle();
    const double& a0=data.angle1;
    const double& a1=data.angle2;
   (...)
}