I'm a bit of a newie with C++, and can't determine where to "declare" the functions in the following code. The compiler is stating I haven't defined the functions, but I've followed the instructors directions, and am now stuck. YAY! Thanks so much!
using namespace std;
int main( ) // calls readmiles & calcKM
int numMiles = 0;
double distKilo = 0.0;
numMiles = readmiles( );
cout << "Total miles in kilometers is : " << distKilo << endl;
int readmiles( ) //inputs number of miles
cout <<"Enter number of miles: ";
cin >> numMiles;
double calcKM(int numMiles) // calculates miles into kilometers
distKilo = numMiles * 1.67;
Step One: Please in future post code using the (CODE) button, which gives lots of good effect for very very little effort. (Please also look for the 'thread is solved' link at the bottom and after the thread is really solved be sure to mark it solved: That, too, gives good effect for very little effort.
The compiler sees thing in the order they are shown in the file. If main() needs to call readmiles() then readmiles() needs to be at least declared (if not defined) before main is seen. For this particular program, just re-order things. For larger programs, you will learn to create a header file that declares functions, classes, etc; then #include that header before the code that uses the declared "things". The body of the function (the implementation, also called definition) can be seen later as long as the linker can find it somewhere.