I’ve also tried to put the #include "TankAimingComponent.h"
in the Tank.cpp instead of the Tank.h, but this throws an error. Why is that?
ok, after watching the next video I’ve sorted it out by defining a forward decleration in Tank.h like this: class UTankAimingComponent;
and then cutting out the #include "TankAimingComponent.h"
from Tank.h and pasting it into Tank.cpp.
The question remains, though: Why is it possible in TankPlayerController to move the #include "Tank.h"
from the header file to the cpp file, without a forward decleration in TankPlayerController.h, but not moving the include of TankAimingComponent from Tank.h to Tank.cpp without a forward decleration in Tank.h?
Sorry to be confusing, but as this is a question requiring an answer could you use the Udemy Q&A for this sort of thing. For everything else this is the please, I think you’ll get the quickest response there.
Having said that it would be a bad service not to answer your question while I’m here. We do have a forward declaration of ATank
in the `TankPlayerController.h’ later in a couple of videos time. Sorry it’s confusing.
It’s just a quirk of using the engine. Somewhere in the build chain ATank gets #include
into the AI/PlayerController from generated headers or macros.
That said, it’s probably best not to rely on these things.
Think you misunderstood, you might have it but if you comment it out you’ll find it still compiles.
Thanks for the answer. I will have to get more into C++ compilation processes, especially in context of the Unreal Engine. I don’t feel 100% sure about why certain things happen or won’t work, but others do.