I'm reading the book C++ Primer Plus (6th Edition) and I've come across something that is kind of confusing to me, so bear with me while I try to explain...
If I have a function whose prototype looks like so:
void cube(double x);
and another function who prototype looks like so:
void cube(const double &x);
what is the difference between the two? For the first function prototype, the value is passed by value meaning that it will be copied and thus unaltered by the function. For the second prototype, the value is passed by reference but it's a constant reference so C++ will create an anonymous temporary variable and assign the value of the argument to the temporary variable thus mimicking pass by value. So, in essence there is really no difference between the two function prototypes, right? What is the point of (const double &x) then?