So, I’m following the C++ Tanks vs Zombies Live Training videos from Unreal Engine’s YT channel, and I’ve done everything right to this point (I’m currently setting up the binds for the player’s movement), but every component I use on my code I have to manually include its header file on my header. On the videos they simply type
First of all, for the most part you can ignore red underlines. Intellisense doesn’t know much about UE4 and it’s macros.
Secondly, in order to use or call functions on a class - the .cpp file needs to know what that class is. Including other headers in your own header is a bad idea because it leads to circular dependencies and bloated binaries very quickly. A better approach is to use forward declaration, and include headers in your .cpp file. Recently the engine is adopting this rule a bit better, and so you typically need to add more headers to your files to access various classes.
In order to declare a UInputComponent for example with Forward Declaration, do this:
// Underneath #includes
/// MyClass code
The limitation of forward declaration is that you cannot access member variables or call functions on that class from your own header, but unless your inlining a bunch of stuff you shouldn’t need to do that anyway.
The Tutorial you are following probably uses pre-4.15 include model when everything was in monolithic headers so everything was always included anyway and you never had to worry about it.
The problem with that approach is it increases compile time drastically, so Epic moved to an include what you use (IWYU) model which speeds up compilation but requires you to include things manually now.