Quote:
Originally Posted by phae36
void calcTime(milliseconds);
{
double seconds = milliseconds / 1000.0;
double minutes = seconds / 60.0;
double hours = minutes / 60.0;
}
this is supposed to be the function to calculate, and i have no idea how to put together the other functions
|
Well, that's a start. Not overly impressed with the effort though...
A common mistake for beginners is to put a semicolon after the function declaration.
Your other problem is you failed to declare milliseconds, that is milliseconds has no data type, so the program doesn't know what to do with it. This will give a fairly self explanatory compile error.
Other than that, your function will work just fine. If you would like to make milliseconds a pass by reference instead of value, throw an ampersand (&) in front of it.
This appears to be a very good guide on functions in C++.
http://www.cplusplus.com/doc/tutorial/functions/
This one explains the difference between reference and value and how to use them. Basically, when you pass a variable by value, you are sending a copy of the variable. When you pass a variable by reference you are sending the variable, or more specifically, I believe you are passing the address of the variable.
http://www.cplusplus.com/doc/tutorial/functions2/
Read those two pages, and write the other three functions. If you are having an issue with the insides of the functions, ignore them for now. Just declare the functions and get them to compile. Then worry about the insides.