IMPORTANT2 Flashcards
Computer misuse act, make…
supplying or obtain
If not specified, are parameters passed by value or by ref?
by value
What happens if a parameter is passed by value?
a copy of the variable is passed to the subroutine where it is treated as a local variable thus protecting it from being changed by the subroutine but also using additional memory space. It is destroyed when the subroutine has completed.
What happens if a parameter is passsed by reference
the reference to the memory location of the variable itself is passed Therefore if the value of the variable is changed, it remains changed after the subroutine ends. A literal value can’t be passed by reference obviously as it has no reference (more applicable to recursive subroutines).
How do you pass parameters by value and by reference?
procedure calculateTotal(x:byVal, y:byRef)