previous | start | next

## Array Parameters

- If a function adds elements to an array, you need to pass the array, the maximum size, and the current size.
- The current size must be passed as a reference parameter.

  >     void read_data(double a[], int a_capacity, int& a_size)
  >     {
  >        a_size = 0;
  >        while (a_size < a_capacity)

  >        {
  >           double x;
  >           cin >> x;
  >           if (cin.fail()) return;
  >           a[a_size] = x;
  >           a_size++;
  >        }
  >     }

- Arrays cannot be function return types.
- To "return" an array, the caller of the function must provide an array parameter to hold the result.

previous | start | next