The exercise is trying to teach you how to start using multiple source files and headers, this then makes your work change from everything being lumped into one large file with lots of code lines, to a 'project' where code is spread out amongst files and resources and as such makes for a much better way of managing your work, for example all of your error output can be moved into a file like 'error.cpp', all of your menu work in 'menu.cpp' etc etc.
You always need a source file with 'int main()' in it, but when you start using multiple source files you will find that contrary to what you might be writing now your 'main()' file may only have a few lines in it, the rest of the action is diverted out to the supporting source files once you build your objects, start your algorithms or whatever.
In the exercise you are basically required to add one source file and one header to a project.
Often there will be one header and one source for each category, so you get pairs, like 'menu.cpp' goes with menu.h' etc.
so in the header simply write the function prototype for now, with a comment to say what it does.
like:
Code:
void ShowOutput(); //prints details of this function
Then in the extra source file mysource.cpp, include your header (like when you write include<iostream>) dont use the <> though, use "myheader.h" for your own stuff.
And in this file write the body of the function so that it prints out the details required.
then in the normal source file containing main() also include myheader.h
and call 'ShowOutput()'
For further info a header file is included in the 'pre-processing' of the build.
Thus the contents of a header let the compiler know 'ahead' of time about e.g functionality and datatypes that may be used in the actual source files.
Regarding the recommendation to use parameter names in function declarations:
a prototype like this:
Code:
void DrawLine(int, int, int, int); //draws a line
is absolute crapola.
It is left to the programmer that picks this up (and you..) to infer what the four ints may mean.
much better is somethng like :
Code:
void DrawLine(int xStart, int yStart, int xEnd, int yEnd); //draws a line from the x, y start positions to the x, y end positions
And in your source file you may well call:
Code:
DrawLine(currXstart, currYstart, currXend, currYend );
the reader of this file understands that the present relative coordinates are being passed away to the function.
the reader of the prototype does not need to see the arguments as 'currentX' or whatever, they just see that the function operates on four well described parameters that make sense in relation to the function name and work it does.