Pass By Reference
Mississippi College
Computer Science
Dr. Bennet
CSc 404
Overview
Syntax
Names and Scope
Types
Semantics
Functions
By Ref
By Val Res
By Name
Jensen's Device
Pass-By-Name Impl
Java MR
Var Loc
Ada Pass
Passing Prob
Pascal Dyn
Java Dyn
Logic Pgmming
Memory Management
Modular and Class Abstraction
Functional Programming
#include <iostream> using namespace std; void f(int &a, int &b) { a = a + 3; b = b + 5; } main() { int x = 10; int y = 25; f(x,y); cout << x << " " << y << endl; x = 10; f(x,x); cout << x << endl; }
[download]
Prints 13 30 18