Why does this version of the swap function fail to work? Is there a fix?
```
void swap(int & lhs, int& rhs)
{
lhs = rhs;
rhs = lhs;
```
a) Of course it works! Just look at it. It clearly swaps the two parameters!
b) It fails because the programmer forgot to make the parameters call-by-reference.
c) It fails OK, and we can fix it we can just reverse the order of the lines.
d) It fails because the first line destroys the old value of lhs without saving it.
Then both variables have the old value of rhs in them.
e) To fix this, we must save the lhs value in a local variable before making the
first assignment indicated, then instead of the second line, assign the rhs the
value of the local variable:
d) It fails because the first line destroys the old value of lhs without saving it.
Then both variables have the old value of rhs in them.
e) To fix this, we must save the lhs value in a local variable before making the
first assignment indicated, then instead of the second line, assign the rhs the
value of the local variable
You might also like to view...
Blender's development started in 2002, but it wasn't open-sourced until 2008 when the new and
revamped 2.50 version was being developed. Indicate whether the statement is true or false
The firewall administrator is adding a new certificate for the company's remote access solution. The solution requires that the uploaded file contain the entire certificate chain for the certificate to load properly. The administrator loads the company certificate and the root CA certificate into the file. The file upload is rejected.Which of the following is required to complete the certificate chain?
A. Certificate revocation list B. Intermediate authority C. Recovery agent D. Root of trust