The above code is equivalent to header guards, as seen in the following code. It is used to make sure things are only declared exactly once. Examples of when they are needed are circular inclusion and polymorphism.

The above code is equivalent to header guards, as seen in the following code. It is used to make sure things are only declared exactly once. Examples of when they are needed are circular inclusion and polymorphism.

In the case of circular inclusion, it is often possible to omit including the header of the other class and simply use a forward declaration, as seen here:

class GameObject; // instead of "#include <GameObject.h>

But dont Forward declarations prevent you from accessing methods and variables from the objects? If i want to create a new player with the object creator, and a new bullet with the player, how do I access the methods?

Look at the source file, it includes GameObject.h. The header only uses a pointer to GameObject, so it doesn't actually need to know about it. The source file is what is actually using it, hence why you include it there. Since pointers and references are known sizes, the compiler can use them without full definitions of types.

Also, why is your factory method in a class when it could just be a free function in this case?