Introduction / Context:
When functions or modules interact, they often exchange data via parameters. The way those parameters are transmitted determines whether the callee can alter the caller's original variable. This question asks for the term describing the practice of sending only a copy of the data to the callee.
Given Data / Assumptions:
- The callee should not modify the caller's original variable through the parameter.
- Common parameter-passing modes include by value, by reference, and by pointer.
- We focus on the copy semantics.
Concept / Approach:
- Passing a value (pass-by-value) duplicates the data for the function's use.
- Making a reference creates an alias, enabling mutation of the original.
- Recursion is a control-flow pattern, not a data-passing mode.
Step-by-Step Solution:
Identify the desired behavior: callee gets only a copy of the data.Associate this with the term: passing a value.Therefore, the correct answer is ”passing a value”.
Verification / Alternative check:
Example: void f(int x){ x = 42; } int a=10; f(a); After the call, a remains 10 because x is a copy.
Why Other Options Are Wrong:
- making a reference: Allows in-place modification of the caller's variable.
- recursion: Unrelated concept.
- setting a condition: Refers to control flow, not parameter semantics.
- None of the above: Incorrect because passing a value is the standard term.
Common Pitfalls:
- Passing large objects by value can be expensive; consider const references or moves.
- Believing pass-by-value prevents all side effects; global state and pointers inside objects can still be modified.
Final Answer:
passing a value
Discussion & Comments