ch9Mar6 - Chapter 9 Subprograms, cont'd 9.5.4 Parameter...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 9 Subprograms, cont'd 9.5.4 Parameter passing in common lang.s 9.5.5 Type Checking Parameters 9.5.6 Multidimensional Arrays as Parameters 9.5.7 Design Considerations 9.5.8 Examples of Parameter Passing
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
9.5.4 Parameter passing in common lang.s C language pass-by-value (in-mode) pass-by-reference (inout mode) . .. using ptr pass-by-reference (in mode) . .. const int * p void fun(const int * f) { *f = 44 ; // error: assignment to a read-only location }
Background image of page 2
C++ pass-by-value (default) pass-by-reference using pointer constant parameters vs in-mode param.s in-mode, by ref. by-value inout by ref.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java pass-by-value in all cases but effectively by-reference for objects and by-value for scalars the actual reference cannot be changed but the object can.
Background image of page 4
what is the output? public static void move(Rectangle box1, Rectangle box2) { box1 = box1.translate(15, 10) ; box2 = box1 ; } .... Rectangle boxA = new Rectangle(0, 0, 0, 0) ; Rectangle boxB = new Rectangle(10, 20, 30, 40) ; move(boxA, boxB) ; System.out.println(boxA.getX() + “ “ + boxB.getX()) ;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Ada pass-by-value or by-result, or by-reference procedure Sub(A : in out Integer, B : in Integer, C : out Float) in is the default method, can be referenced but not assigned out can be assigned but not referenced in out can be both assigned and referenced all scalars are passed by copy all structures are passed by reference
Background image of page 6
Fortran95 also uses all three parameter passing methods Subroutine Sub(A, B, C) Integer, Intent(Inout) :: A Integer, Intent(In) :: B Integer, Intent(Out) :: C
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C# pass-by-value is the default by-reference when both formal and actual parameters are preceded by ref void sub(ref int f1, int f2, out int f3) {. ..} sub(ref a1, a2, a3) ; a1 is passed by-reference (inout mode) a2 is passed by value (in mode) a3 is passed by result (out mode)
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/29/2010 for the course COMPUTER S cps615 taught by Professor Pro during the Spring '10 term at Randolph College.

Page1 / 27

ch9Mar6 - Chapter 9 Subprograms, cont'd 9.5.4 Parameter...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online