Home Segments Index Top Previous Next

104: Mainline

Because display_box_car_volume has no return statement, it is said to fall off its end, returning nothing, which is allowed for only those functions that have a void return type.

Some programmers think it inelegant to have functions that fall off the end. Accordingly, those programmers write empty return statements, as in the following amended version of display_box_car_volume:

void display_box_car_volume (int h, int w, int l) {
  cout << "The volume of the box car is " << h * w * l << endl;
  return;  
}