Then I have one last hassle, why do you put your includes in the .cpp files? The Headers can compile without any other classes now, but the body cannot. Is there an upside/downside?
One of the main reason to do this is to reduce compile-time dependencies between modules and classes by separating the implementation from the declaration in the headers. This will increase the compile-speed and also allow you to separate modules better. Usually you only need to know the declaration (method-footprints) of a class and not the definition (implementation) of said methods in another class. The problem behind it is, that in c++ includes are always visible from the outside even if all the methods and class-attributes are declared private.
One of the downside of forward declaration is, that you can only use forward declared classes by using pointers and references and not by value, which may be a bit confusing if you are used to Java/C#.
Here is a simple example:
Say you have a base class "MyBaseClass" which internally (private) uses some helper class and another class that inherits from MyBaseClass. If you include the helper-class in your header like this:
[source lang="cpp"]// file MyBaseClass.h#include "SomeHelperClass"class MyBaseClass{public: // whater is neededprivate: SomeHelperClass myImplementationHelper;}// file MyDerivative.h#include "MyBaseClass.h"class MyDerivative : public MyBaseClass{public: ... // whatever you need}[/source]
If you have changes in SomeHelperClass.h the compiler will of course recompile MyBaseClass which directly uses the helper. But since you indirectly include SomeHelperClass.h also in MyDerivative this will also be recompiled even if MyDerivative has not changed at all. So you compile three cpp files instead of only two. Would you use a forward declaration of SomeHelperClass in your base class and only include the header in MyBaseClass.cpp, you would only need to compile two.
I hope this helps.
edited some typos