I'm learning C++ and I'm wondering about better possibilities to define function parameters.
I know there are a lot of cases where it's obvious but I'm interested how is it in general. For example in this simple case:
void UpdateIfGreater(int first, int& second) {
if (first > second) {
second = first;
}
}
// or if I define the first parameter as a constant link it'll be more effective?
void UpdateIfGreater(const int& first, int& second) {
if (first > second) {
second = first;
}
}
It will be strange if the second one is more effective since the code is becoming uglier but there is no variable copying.