Fiveable
Fiveable

Pass-by-value

Definition

Pass-by-value is the method of passing arguments to functions or methods by creating copies of their values instead of directly passing references to them.

Analogy

Think of pass-by-value like making photocopies. When you want to share information with someone, you make copies of the original document and give them out. Each person gets their own copy, which they can modify without affecting the original document.

Related terms

Pass-by-reference: A method of passing arguments where the memory address (reference) is passed instead of creating copies.

Call stack: A stack-like data structure that keeps track of function calls during program execution.

Return value: The value that is returned by a function after it completes its execution.



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.