190k views
1 vote
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter

A. reference
B. global
C. constant
D. value

1 Answer

2 votes

Final answer:

In function parameter lists, adding an '&' after a dataType specifies that the parameter is a reference, allowing direct modification of the variable.

Step-by-step explanation:

When you attach an & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a reference parameter. This means that instead of passing the value of the variable to the function, a reference to the original variable is passed. This allows the function to modify the variable directly rather than working on a copy. This can be useful when you need a function to modify the incoming parameter, or when you want to avoid the overhead of copying large data structures.

User Stefan Feuerhahn
by
8.0k points