Home Segments Index Top Previous Next

95: Mainline

You define the box_car_volume function as follows:

int box_car_volume (int h, int w, int l) { 
  return h * w * l; 
} 

Here is what each part of a function definition does:

 *--Tells C++ the data type of the returned value 
 |        *-- Tells C++ the name of the function 
 |        |                  *-- Tells C++ the names of the 
 |        |                  |   parameters along with their 
 |        |                  |   data types 
 v        v                  v 
--- -------------- ---------------------  
int box_car_volume (int h, int w, int l) {  <-- Marks where  
  return h * w * l;                             the body begins 
  ------ --------- 
    ^        ^ 
    |        | 
    |        *-- The expression whose value is to be returned 
    *-- Indicates that a value is to be returned by the function 
}  <-- Marks where the body ends