Header files are used to separate the interface (function declarations and public data types) from implementation (how the functions are constructed and how private data types are used). This makes it possible to "hide" the implementation from the end user.
Suppose you have a working program and you find a better algorithm or way to implement a function. You could then change the implementation of the function in the .cpp file, as long as the function parameters remain the same. Then you can simply recompile the program using the new .cpp file. That way there is no need to change the header and main files.
For simple programs and exercises, it is not always necessary to have separate header files, however, for larger programs with many classes or programs with classes to be used by other end users, I find it a good habit to use separate header and definition files.
For a more extended discussion check out:
http://en.wikipedia.org/wiki/Header_file
You should also read "Thinking in C++, Vol.1" by Bruce Eckel, which you can download from several sources online.
Hope this helps.