> But I don't understand the fuss about the cpp files though,
> if it is so simple to keep it all in a header (?!)
As the size of the code base becomes larger, it is not so simple. We would want to separate the declaration from the implementation for a variety of reasons. For example,
If we make a small change to the implementation, we wouldn't want to recompile and retest every file that used the component.
We might want to package the implementation into a separate library which contains the already compiled code and provide the library along with a set of headers to the users of the library. For example, the header
contains the declarations of various regex functions, and libc++ contains their implementations.
This model - called 'the separate compilation model' - is essential to promote modularity and loose coupling.
However, the separate compilation model can't be used with templates; a template definition is not code in the classical C sense. With templates, a class or a functions is created when the template is instantiated; to be able to instantiate the template, the compiler needs to see the definition of the template at compile time.