However, when the actual parameter content will definitely be modified, and this modification cannot affect the original variable, it is more suitable not to quote it.
When using non-const references and the actual parameters are literal values, expressions, or objects of different types that need to be converted. Such as void swap(int &a,int &b); int a=2; double b=3.0; f(a,5); f(a+2,a ); f(a,b); will not work. You can't use const int& either, because the values of a and b need to be exchanged.
It’s really hard to find such examples.
However, when the actual parameter content will definitely be modified, and this modification cannot affect the original variable, it is more suitable not to quote it.
For example:
In the above example, is it better not to use a reference for the first parameter path?
What hibernake said is right, my example is inappropriate
When using non-const references and the actual parameters are literal values, expressions, or objects of different types that need to be converted. Such as
void swap(int &a,int &b);
int a=2;
double b=3.0;
f(a,5);
f(a+2,a );
f(a,b);
will not work. You can't use const int& either, because the values of a and b need to be exchanged.