Skip to main content

13.3) void Functions


void print_values(double[] data, int size)
{
  for (int i = 0; i < size; ++i) {
    cout << data[i] << '\n';
  }
  // no return statement in function
}

void indicates that no value is returned by function, so code such as this will not work:

result = print_values(data, size);

It is still possible for such functions to transfer the results of computation back to the caller via the parameter list, if parameters are specified as pointers or references (see later)