?
=?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunion?=
Hello.
Binding a temporary to a non-const reference is illegal. Everybody
should be tired of hearing that. So should I. But then I found myself
wondering about a small piece of code I was writing:
void cipher(unsigned long& xa, unsigned long& xb)
{
// ...
xa = // ...
xb = // ...
}
int main()
{
unsigned long a = 1111111;
unsigned long b = 2222222;
cipher(a, b);
}
The function cipher() is supposed to transform the two /long/ arguments
received. It might have had its arguments in the form of pointers, but
the author chose to allow users to use a simple, uncluttered cipher(a,
b) call. It might also have been made to return an object containing the
two ciphered values instead.
Which of the two alternatives aforementioned do you think is better? Is
there any other one I have overlooked?
Thank you,
Binding a temporary to a non-const reference is illegal. Everybody
should be tired of hearing that. So should I. But then I found myself
wondering about a small piece of code I was writing:
void cipher(unsigned long& xa, unsigned long& xb)
{
// ...
xa = // ...
xb = // ...
}
int main()
{
unsigned long a = 1111111;
unsigned long b = 2222222;
cipher(a, b);
}
The function cipher() is supposed to transform the two /long/ arguments
received. It might have had its arguments in the form of pointers, but
the author chose to allow users to use a simple, uncluttered cipher(a,
b) call. It might also have been made to return an object containing the
two ciphered values instead.
Which of the two alternatives aforementioned do you think is better? Is
there any other one I have overlooked?
Thank you,