From C to C++
- slide 23 : 29
Call-by-reference parameters via pointers
A
call-by-reference parameter
in C is a pointer passed as a
call-by-value parameter
Motivation
Output parameters
Input parameters: Avoid copying large data structures
Examples
The struct functions discussed earlier
Structs and functions
A C program with a swap function.
C++ offers a
reference type
that establishes an alias to an existing location in memory