Answer the following statements true (T) or false (F)

1. There is only one kind of parameter passing in C++, namely call-by-value.
Explain.
2. The call-by-reference mechanism is specified in the function declaration and
definition, using a $ between the type and the parameter.
3. The position of the ampersand in the function header is of no importance to the
proper compiling and execution of code that uses call-by-reference parameters.
4. A call-by-value parameter may pass data only into a function.
5. A call-by-reference parameter may pass data only out of a function.


1. False.
There is also call-by-reference. Call-by-value makes a copy of the
argument then uses that, hence does not make changes to the argument. Call-by-reference
effectively passes the argument hence can make changes to the argument.
2. False
The character is an ampersand, &, not a $. It is placed between the type
and the parameter to indicate a call-by-reference parameter.
3. True
It makes no difference whether the ampersand appears next to the type
or the variable.
```
void example3(double &ref_to_dbl);
void example3(double& ref_to_dbl);
//In a call to this function ref_to_dbl becomes a
// reference to double that refers to the argument.
```
4. True.
The value parameter is essentially a local variable initialized to the
value of the argument at the time of a call.
5. False.
The reference parameter is an alias for the caller's argument. The
mechanism is to pass the address of the argument which is used where the parameter
occurs. Hence, a reference parameter makes available to the function the initial and
ongoing values of the caller's argument as well as providing a mechanism for the
function to change the caller's argument.

Computer Science & Information Technology

You might also like to view...

can be written as:

Java supports type inferencing with the <> notation in statements that declare and create generic type variables and objects. For example, the following line: List list = new ArrayList(); a. List<> list = new ArrayList<>(); b. List<> list = new ArrayList(); c. List list = new ArrayList<>(); d. List list = new ArrayList();

Computer Science & Information Technology

The code for the sequential search implementation is so succinct that writing it inline instead of writing a function is preferable.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

You can publish an existing document as a blog post by clicking the File tab, clicking ____, and then clicking Post to Blog.

A. Print B. Export C. Options D. Share

Computer Science & Information Technology

Which of the following devices would MOST likely have a DMZ interface?

A. Firewall B. Switch C. Load balancer D. Proxy

Computer Science & Information Technology