Modify a void function to a value-returning
mac193 (6)
Nov 3, 2012 at 8:04pm UTC
I'm not sure how to change a void function into a value-returning one. The function we were given for class is,
void convertToMeters (int ft, double in, double& m);
Moschops (5961)
Nov 3, 2012 at 8:06pm UTC
To make it return an int:
int convertToMeters (int ft, double in, double & m);
and stick return someInt; in it.
BlackSheep (388)
Nov 3, 2012 at 8:07pm UTC
1 2 3 4 5
double convertToMeters (int ft, double in, double & m)
{
//Conversion
return meters;
}
Although you're passing m (meters?) by reference which means that any changes inside the function will affect the variable outside the function.