Can I overload a function which takes either a reference or variable name?
For example when I try to do this:
void function(double a);
void function(double &a);
I would like the caller of this function to be able to do:
double a = 2.5;
function(a); // should call function(double &a)
function(2.3); // should call function(double a)
I would like to write pass-by-reference functions for better memory use and possible manipulation of the variable outside of scope, but without having to create a new variable just so I can call the function.
Is this possible?
Cheers