Return to Topic Menu | Computer Science Main Page | | Terms of Use | Resource CD

Multi-Dimensional Arrays and Functions

 C++ passes all arrays, including matrices, by address.
(Remember the mantra!!!)

The name of the array is the address
of the first element of the array."

Suppose that you were using a matrix called scores, represented in a 5-by-6 table. You could pass this matrix, scores, to a function named print_it( ), with the following function call:

print_it(scores);   // Passes matrix to function

The definition of the print_it( ) function could be:

void print_it(apmatrix<int> &scores)
{ . . . // Function definition